Class: MiniToken
- Inherits:
-
Struct
- Object
- Struct
- MiniToken
- Defined in:
- lib/mini_token.rb
Constant Summary collapse
- TOKEN_SIZE =
6
- TOKEN_CHARACTERS =
(('A'..'Z').to_a+('a'..'z').to_a+('0'..'9').to_a)
- DB_PATH =
File.(File.join(File.dirname(__FILE__), '..', 'db'))
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
- .all ⇒ Object
- .delete_token(param) ⇒ Object
- .find(param) ⇒ Object
- .output(size = nil) ⇒ Object
- .truncate_tokens ⇒ Object
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db
4 5 6 |
# File 'lib/mini_token.rb', line 4 def db @db end |
#token ⇒ Object
Returns the value of attribute token
4 5 6 |
# File 'lib/mini_token.rb', line 4 def token @token end |
Class Method Details
.all ⇒ Object
30 31 32 33 |
# File 'lib/mini_token.rb', line 30 def all connection @db.all end |
.delete_token(param) ⇒ Object
19 20 21 22 |
# File 'lib/mini_token.rb', line 19 def delete_token(param) connection @db.filter(:token => param).delete end |
.find(param) ⇒ Object
24 25 26 27 28 |
# File 'lib/mini_token.rb', line 24 def find(param) connection t = @db.first(:token => param) t[:token] unless t.nil? end |
.output(size = nil) ⇒ Object
10 11 12 |
# File 'lib/mini_token.rb', line 10 def output(size = nil) generate { @token_size = size.nil? ? TOKEN_SIZE : size } end |
.truncate_tokens ⇒ Object
14 15 16 17 |
# File 'lib/mini_token.rb', line 14 def truncate_tokens connection @db.truncate end |