Module: Cash::Config::ClassMethods

Defined in:
lib/cash/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(a_class) ⇒ Object



10
11
12
13
14
15
# File 'lib/cash/config.rb', line 10

def self.extended(a_class)
  class << a_class
    delegate :repository, :indices, :to => :cache_config
    alias_method_chain :inherited, :cache_config
  end
end

Instance Method Details

#cache_configObject



17
18
19
20
21
22
23
24
# File 'lib/cash/config.rb', line 17

def cache_config
  unless c = @cache_config
    if self.superclass.respond_to?(:cache_config) && (c = self.superclass.cache_config)
      c.inherit(self)
    end
  end
  @cache_config
end

#cache_config=(config) ⇒ Object



40
41
42
# File 'lib/cash/config.rb', line 40

def cache_config=(config)
  @cache_config = config
end

#index(attributes, options = {}) ⇒ Object



31
32
33
34
# File 'lib/cash/config.rb', line 31

def index(attributes, options = {})
  options.assert_valid_keys(:ttl, :order, :limit, :buffer)
  (cache_config.indices.unshift(Index.new(cache_config, self, attributes, options))).uniq!
end

#inherited_with_cache_config(subclass) ⇒ Object



26
27
28
29
# File 'lib/cash/config.rb', line 26

def inherited_with_cache_config(subclass)
  inherited_without_cache_config(subclass)
  cache_config.inherit(subclass)          
end

#version(number) ⇒ Object



36
37
38
# File 'lib/cash/config.rb', line 36

def version(number)
  cache_config.options[:version] = number
end