Class: Chef::Cache

Inherits:
Object show all
Includes:
Mixin::ConvertToClassName, Singleton
Defined in:
lib/chef/cache.rb,
lib/chef/cache/checksum.rb

Direct Known Subclasses

Checksum

Defined Under Namespace

Classes: Checksum

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Constructor Details

#initialize(*args) ⇒ Cache

Returns a new instance of Cache.



34
35
36
# File 'lib/chef/cache.rb', line 34

def initialize(*args)
  self.reset!(*args)
end

Instance Attribute Details

#monetaObject (readonly)

Returns the value of attribute moneta.



32
33
34
# File 'lib/chef/cache.rb', line 32

def moneta
  @moneta
end

Instance Method Details

#reset!(backend = nil, options = nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chef/cache.rb', line 38

def reset!(backend=nil, options=nil)
  backend ||= Chef::Config[:cache_type]
  options ||= Chef::Config[:cache_options]
  
  begin
    require "moneta/#{convert_to_snake_case(backend, 'Moneta')}"
  rescue LoadError => e
    Chef::Log.fatal("Could not load Moneta back end #{backend.inspect}")
    raise e
  end
 
  @moneta = Moneta.const_get(backend).new(options)
end