Class: CacheAdvance::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/cache_advance/mapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(cache_set) ⇒ Mapper

Returns a new instance of Mapper.



3
4
5
# File 'lib/cache_advance/mapper.rb', line 3

def initialize(cache_set)
  @cache_set = cache_set
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, options = {}) ⇒ Object



22
23
24
# File 'lib/cache_advance/mapper.rb', line 22

def method_missing(method, options={})
  @cache_set.add_named_cache(method, options)
end

Instance Method Details

#plugin(name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/cache_advance/mapper.rb', line 11

def plugin(name)
  if name.is_a?(Symbol)
    plugin = name.to_s.camelcase.constantize.new
  elsif name.is_a?(Class)
    plugin = name.new
  else
    plugin = name
  end
  @cache_set.add_plugin(plugin)
end

#qualifier(name, &proc) ⇒ Object



7
8
9
# File 'lib/cache_advance/mapper.rb', line 7

def qualifier(name, &proc)
  @cache_set.add_qualifier(name, proc)
end