Module: DeltaChanges::Extension
- Defined in:
- lib/delta_changes.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/delta_changes.rb', line 5 def self.included(base) base.extend(ClassMethods) base.cattr_accessor :delta_changes_options base.attribute_method_suffix '_delta_changed?', '_delta_change', '_delta_was', '_delta_will_change!' base.send(:alias_method, :write_attribute_without_delta_changes, :write_attribute) base.send(:alias_method, :write_attribute, :write_attribute_with_delta_changes) end |
Instance Method Details
#delta_changes ⇒ Object
45 46 47 |
# File 'lib/delta_changes.rb', line 45 def delta_changes delta_changed_attributes.keys.inject({}) { |h, attr| h[attr] = attribute_delta_change(attr); h } end |
#delta_changes? ⇒ Boolean
49 50 51 |
# File 'lib/delta_changes.rb', line 49 def delta_changes? delta_changed_attributes.keys.present? end |
#reset_delta_changes! ⇒ Object
55 56 57 |
# File 'lib/delta_changes.rb', line 55 def reset_delta_changes! delta_changed_attributes.clear end |