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(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(options, &block)
  @cache, @backend = options[:cache], options[: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.

Raises:

  • (ArgumentError)


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.

Raises:

  • (ArgumentError)


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

#resultObject

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