Module: CacheBack::DirtyMixin

Defined in:
lib/cache_back/dirty_mixin.rb

Instance Method Summary collapse

Instance Method Details

#cache_back_dirty_methods(*method_names) ⇒ Object Also known as: cache_back_dirty_method



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/cache_back/dirty_mixin.rb', line 3

def cache_back_dirty_methods(*method_names)
  method_names.each do |method|
    unless method_defined?("without_cache_back_update_#{method}")
      alias_method("without_cache_back_update_#{method}", method)
      define_method(method) do |*args|
        result = send("without_cache_back_update_#{method}", *args)
        clear_cache_back_indices
        result
      end
    end
  end
end