Class: MortalToken
- Inherits:
-
Object
- Object
- MortalToken
- Defined in:
- lib/mortal-token/mortal-token.rb,
lib/mortal-token/token.rb,
lib/mortal-token/version.rb,
lib/mortal-token/configuration.rb
Overview
A token hash that “self-destructs” after a certain time.
Defined Under Namespace
Classes: Configuration, Token
Constant Summary collapse
- VERSION =
Library version
'0.1.0'
- CONFIGS =
:nodoc:
{}
- UNITS =
:nodoc:
{days: {increment: 1, format: '%Y-%m-%d'}, hours: {increment: 3600, format: '%Y-%m-%d_%H'}, minutes: {increment: 60, format: '%Y-%m-%d_%H:%M'}}
Class Method Summary collapse
-
.config(name = :default) {|config| ... } ⇒ Object
(also: use)
Returns a new or existing MortalToken::Configuration.
-
.method_missing(method, *args, &block) ⇒ Object
Alias all other methods to the default Configuration.
-
.new(salt = nil, time = nil) ⇒ Object
Returns a new Token.
Class Method Details
.config(name = :default) {|config| ... } ⇒ Object Also known as: use
Returns a new or existing MortalToken::Configuration. If you pass a block, it will pass it the config object. If it’s a new config, it will inherit the default settings.
14 15 16 17 18 |
# File 'lib/mortal-token/mortal-token.rb', line 14 def config(name=:default) config = (CONFIGS[name] ||= Configuration.new(name)) yield config if block_given? config end |
.method_missing(method, *args, &block) ⇒ Object
Alias all other methods to the default Configuration
23 24 25 |
# File 'lib/mortal-token/mortal-token.rb', line 23 def method_missing(method, *args, &block) config.send(method, *args, &block) end |
.new(salt = nil, time = nil) ⇒ Object
Returns a new Token. Also alised to #token.
8 9 10 |
# File 'lib/mortal-token/mortal-token.rb', line 8 def new(salt=nil, time=nil) config.token(salt, time) end |