Class: FmRest::TokenStore::Moneta

Inherits:
Base
  • Object
show all
Defined in:
lib/fmrest/token_store/moneta.rb

Constant Summary collapse

DEFAULT_ADAPTER =
:Memory
DEFAULT_PREFIX =
"fmrest-token:".freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#options

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Moneta

Returns a new instance of Moneta.

Parameters:

  • options (Hash) (defaults to: {})

    Options to pass to Moneta.new

Options Hash (options):

  • :adapter (Symbol) — default: :Memory

    The Moneta adapter to use

  • :prefix (String) — default: DEFAULT_PREFIX

    The prefix to use for keys



26
27
28
29
30
31
32
# File 'lib/fmrest/token_store/moneta.rb', line 26

def initialize(options = {})
  options = options.dup
  super(options)
  adapter = options.delete(:adapter) || DEFAULT_ADAPTER
  options[:prefix] ||= DEFAULT_PREFIX
  @moneta = ::Moneta.new(adapter, options)
end

Instance Attribute Details

#monetaObject (readonly)

Returns the value of attribute moneta.



18
19
20
# File 'lib/fmrest/token_store/moneta.rb', line 18

def moneta
  @moneta
end

Instance Method Details

#delete(key) ⇒ Object



38
39
40
# File 'lib/fmrest/token_store/moneta.rb', line 38

def delete(key)
  moneta.delete(key)
end

#load(key) ⇒ Object



34
35
36
# File 'lib/fmrest/token_store/moneta.rb', line 34

def load(key)
  moneta[key]
end

#store(key, value) ⇒ Object



42
43
44
# File 'lib/fmrest/token_store/moneta.rb', line 42

def store(key, value)
  moneta[key] = value
end