Skip to content

Commit ff34c49

Browse files
committedJul 9, 2012
Update README with proper formatting.
1 parent 5ddfd62 commit ff34c49

File tree

1 file changed

+46
-16
lines changed

1 file changed

+46
-16
lines changed
 

‎README.md

+46-16
Original file line numberDiff line numberDiff line change
@@ -17,69 +17,99 @@ Simple yet customizable token generator for Rails 3.
1717

1818
* Single token
1919

20-
has_token_on :slug, :length => 3
20+
```ruby
21+
has_token_on :slug, :length => 3
22+
```
2123

2224
* Multiple tokens, same configuration
2325

24-
has_token_on [:slug, :permalink], :length => 3
26+
```ruby
27+
has_token_on [:slug, :permalink], :length => 3
28+
```
2529

2630
* Multiple tokens with individual configuration
2731

28-
has_token_on :slug, :length => 3
29-
has_token_on :permalink, :length => 5
32+
```ruby
33+
has_token_on :slug, :length => 3
34+
has_token_on :permalink, :length => 5
35+
```
3036

3137
* .. or using single hash
3238

33-
has_token_on :slug => { :length => 3 }, :permalink => { :length => 5 }
39+
```ruby
40+
has_token_on :slug => { :length => 3 }, :permalink => { :length => 5 }
41+
```
3442

3543
## Options
3644

3745
Options are as follows:
3846

3947
* :length - token length. Default - 16.
4048

41-
has_token_on :slug, length => 3
49+
```ruby
50+
has_token_on :slug, length => 3
51+
```
4252

4353
* :prepend - prepend something to the beginning of the token. Default - none.
4454

45-
has_token_on :slug, :prepend => "private"
55+
```ruby
56+
has_token_on :slug, :prepend => "private"
57+
```
4658

4759
* :append - append something to the back of the token. Default - none.
4860

49-
has_token_on :slug, :append => "ending"
61+
```ruby
62+
has_token_on :slug, :append => "ending"
63+
```
5064

5165
* :unique - ensure that tokens is unique (checking is performed in the app logic). Default - false.
5266

53-
has_token_on :slug, :unique => true
67+
```ruby
68+
has_token_on :slug, :unique => true
69+
```
5470

5571
* :if - generate token only if provided condition is met. Default - none.
5672

57-
has_token_on :slug, :if => lambda { |record| record.private? }
73+
```ruby
74+
has_token_on :slug, :if => lambda { |record| record.private? }
75+
```
5876

5977
* :on - generates token on certain time: :initialize, :create (default), :update.
6078

61-
has_token_on :slug, :on => :initialize
79+
```ruby
80+
has_token_on :slug, :on => :initialize
81+
```
6282

6383
* :seed - elements or functions that are used to generate hash. Options:
6484
* :securerandom - uses ActiveSupport::SecureRandom.hex (default)
6585

66-
has_token_on :slug, :seed => :securerandom
86+
```ruby
87+
has_token_on :slug, :seed => :securerandom
88+
```
6789

6890
* :guid - uses simple_uuid gem. You should add it to your Gemfile. 36 characters long GUID. Length param is ignored.
6991

70-
has_token_on :slug, :seed => :guid
92+
```ruby
93+
has_token_on :slug, :seed => :guid
94+
```
7195

7296
* ('a'..'z') - a Range. Mixes the range elements up to specified length.
7397

74-
has_token_on :slug, :seed => ('a'..'z')
98+
```ruby
99+
has_token_on :slug, :seed => ('a'..'z')
100+
```
75101

76102
* ['a', 'b', 'c'] - an Array. Mixes the array elements up to specified length.
77103

78-
has_token_on :slug, :seed => ['a', 'b', 'c']
104+
```ruby
105+
has_token_on :slug, :seed => ['a', 'b', 'c']
106+
```
79107

80108
* lambda { 2 * 2 } - a Proc. Executes proc. Length param is ignored.
81109

82-
has_token_on :slug, :seed => lambda { 2 * 2 }
110+
```ruby
111+
has_token_on :slug, :seed => lambda { 2 * 2 }
112+
```
83113

84114
## Generator
85115

0 commit comments

Comments
 (0)
Please sign in to comment.