Class: Moneta::Cache::DSL Private
- Inherits:
-
Object
- Object
- Moneta::Cache::DSL
- Defined in:
- lib/moneta/cache.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #adapter(store = nil, &block) ⇒ Object
- #cache(store = nil, &block) ⇒ Object
-
#initialize(store, &block) ⇒ DSL
constructor
private
A new instance of DSL.
Constructor Details
#initialize(store, &block) ⇒ DSL
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DSL.
18 19 20 21 |
# File 'lib/moneta/cache.rb', line 18 def initialize(store, &block) @store = store instance_eval(&block) end |
Instance Method Details
#adapter(store = nil, &block) ⇒ Object
24 25 26 27 28 |
# File 'lib/moneta/cache.rb', line 24 def adapter(store = nil, &block) raise 'Adapter already set' if @store.adapter raise ArgumentError, 'Only argument or block allowed' if store && block @store.adapter = store || Moneta.build(&block) end |
#cache(store = nil, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/moneta/cache.rb', line 31 def cache(store = nil, &block) raise 'Cache already set' if @store.cache raise ArgumentError, 'Only argument or block allowed' if store && block @store.cache = store || Moneta.build(&block) end |