Module: Kasket::DirtyMixin

Defined in:
lib/kasket/dirty_mixin.rb

Instance Method Summary collapse

Instance Method Details

#kasket_dirty_methods(*method_names) ⇒ Object Also known as: kasket_dirty_method



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

def kasket_dirty_methods(*method_names)
  method_names.each do |method|
    without = "without_kasket_update_#{method}"
    break if method_defined? without

    alias_method without, method
    define_method method do |*args, &block|
      result = send(without, *args, &block)
      clear_kasket_indices
      result
    end
  end
end