Class: Trocla::Stores::Moneta
- Inherits:
-
Trocla::Store
- Object
- Trocla::Store
- Trocla::Stores::Moneta
- Defined in:
- lib/trocla/stores/moneta.rb
Overview
the default moneta based store
Instance Attribute Summary collapse
-
#moneta ⇒ Object
readonly
Returns the value of attribute moneta.
Attributes inherited from Trocla::Store
Instance Method Summary collapse
- #close ⇒ Object
- #formats(key) ⇒ Object
- #get(key, format) ⇒ Object
-
#initialize(config, trocla) ⇒ Moneta
constructor
A new instance of Moneta.
- #search(key) ⇒ Object
Methods inherited from Trocla::Store
Constructor Details
#initialize(config, trocla) ⇒ Moneta
Returns a new instance of Moneta.
5 6 7 8 9 10 11 12 13 |
# File 'lib/trocla/stores/moneta.rb', line 5 def initialize(config, trocla) super(config, trocla) require 'moneta' # load expire support by default = { :expires => true }.merge(store_config['adapter_options'] || {}) @moneta = Moneta.new(store_config['adapter'], ) end |
Instance Attribute Details
#moneta ⇒ Object (readonly)
Returns the value of attribute moneta.
3 4 5 |
# File 'lib/trocla/stores/moneta.rb', line 3 def moneta @moneta end |
Instance Method Details
#close ⇒ Object
15 16 17 |
# File 'lib/trocla/stores/moneta.rb', line 15 def close moneta.close end |
#formats(key) ⇒ Object
23 24 25 26 |
# File 'lib/trocla/stores/moneta.rb', line 23 def formats(key) r = moneta.fetch(key) r.nil? ? nil : r.keys end |
#get(key, format) ⇒ Object
19 20 21 |
# File 'lib/trocla/stores/moneta.rb', line 19 def get(key, format) moneta.fetch(key, {})[format] end |
#search(key) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/trocla/stores/moneta.rb', line 28 def search(key) raise 'The search option is not available for any adapter other than Sequel or YAML' unless store_config['adapter'] == :Sequel || store_config['adapter'] == :YAML r = search_keys(key) r.empty? ? nil : r end |