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



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

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

Instance Method Details

#cache_config=(config) ⇒ Object



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

def cache_config=(config)
  @cache_config = config
end

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



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

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



20
21
22
23
# File 'lib/cash/config.rb', line 20

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