Class: Moneta::Cache::DSL Private

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

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

Raises:

  • (ArgumentError)


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

Raises:

  • (ArgumentError)


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