Class: MortalToken

Inherits:
Object
  • Object
show all
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

'1.0.0'
CONFIGS =

:nodoc:

{}

Class Method Summary collapse

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.

Yields:



13
14
15
16
17
# File 'lib/mortal-token/mortal-token.rb', line 13

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



22
23
24
# File 'lib/mortal-token/mortal-token.rb', line 22

def method_missing(method, *args, &block)
  config.send(method, *args, &block)
end

.new(salt = nil, expires = nil) ⇒ Object

Returns a new Token. Also alised to #token.



7
8
9
# File 'lib/mortal-token/mortal-token.rb', line 7

def new(salt=nil, expires=nil)
  config.token(salt, expires)
end