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
- #backend(store = nil, &block) ⇒ Object private
- #cache(store = nil, &block) ⇒ Object private
-
#initialize(options, &block) ⇒ DSL
constructor
private
A new instance of DSL.
- #result ⇒ Object private
Constructor Details
#initialize(options, &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.
16 17 18 19 |
# File 'lib/moneta/cache.rb', line 16 def initialize(, &block) @cache, @backend = [:cache], [:backend] instance_eval(&block) end |
Instance Method Details
#backend(store = nil, &block) ⇒ Object
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.
21 22 23 24 25 |
# File 'lib/moneta/cache.rb', line 21 def backend(store = nil, &block) raise 'Backend already set' if @backend raise ArgumentError, 'Only argument or block allowed' if store && block @backend = store || Moneta.build(&block) end |
#cache(store = nil, &block) ⇒ Object
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.
27 28 29 30 31 |
# File 'lib/moneta/cache.rb', line 27 def cache(store = nil, &block) raise 'Cache already set' if @cache raise ArgumentError, 'Only argument or block allowed' if store && block @cache = store || Moneta.build(&block) end |
#result ⇒ Object
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.
33 34 35 |
# File 'lib/moneta/cache.rb', line 33 def result [@cache, @backend] end |