module OnChange

Constants

VERSION

Public Instance Methods

run_attribute_change_callbacks(attr_name, *args) click to toggle source
# File lib/on_change.rb, line 8
def run_attribute_change_callbacks(attr_name, *args)
  on_change_callbacks = self.class.on_change_callbacks
  on_change_callbacks.has_key?(attr_name.to_s) && on_change_callbacks[attr_name.to_s].each do |callback|
    callback.is_a?(Proc) ? callback.call(self,attr_name,*args) : send(callback, attr_name, *args)
  end
end
write_attribute_with_callbacks(attr_name, value) click to toggle source
# File lib/on_change.rb, line 15
def write_attribute_with_callbacks(attr_name, value)
  run_attribute_change_callbacks(attr_name, read_attribute(attr_name), value)
  write_attribute_without_callbacks(attr_name, value)
end