Module: SimpleCaches::ClassMethods

Defined in:
lib/simple_caches/simple_cache.rb

Instance Method Summary collapse

Instance Method Details

#simple_cache(target, source) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/simple_caches/simple_cache.rb', line 3

def simple_cache(target, source)
  define_method("cached_value_for_#{target}_#{source}") do
    self.send("#{target}=", self.send(source))
  end

  before_save do
    self.send("cached_value_for_#{target}_#{source}")
  end
end