Module: Dinamo::Model::Dirty
- Extended by:
- ActiveSupport::Concern
- Included in:
- Dinamo::Model
- Defined in:
- lib/dinamo/model/dirty.rb
Instance Method Summary collapse
- #attribute_changed?(attr) ⇒ Boolean
- #changed ⇒ Object
- #changed? ⇒ Boolean
- #changed_attributes ⇒ Object
- #changes ⇒ Object
- #changes_applied ⇒ Object
- #clear_changes_information ⇒ Object
- #clear_previous_attributes ⇒ Object
Instance Method Details
#attribute_changed?(attr) ⇒ Boolean
34 35 36 |
# File 'lib/dinamo/model/dirty.rb', line 34 def attribute_changed?(attr) changed.include?(attr.to_s) end |
#changed ⇒ Object
17 18 19 |
# File 'lib/dinamo/model/dirty.rb', line 17 def changed changed_attributes.keys end |
#changed? ⇒ Boolean
21 22 23 |
# File 'lib/dinamo/model/dirty.rb', line 21 def changed? !changed_attributes.empty? end |
#changed_attributes ⇒ Object
30 31 32 |
# File 'lib/dinamo/model/dirty.rb', line 30 def changed_attributes @changed_attributes ||= ActiveSupport::HashWithIndifferentAccess.new end |
#changes ⇒ Object
25 26 27 28 |
# File 'lib/dinamo/model/dirty.rb', line 25 def changes map = changed.map { |attr| [attr, attribute_change(attr)] } ActiveSupport::HashWithIndifferentAccess[map] end |
#changes_applied ⇒ Object
38 39 40 41 |
# File 'lib/dinamo/model/dirty.rb', line 38 def changes_applied @previously_changed = changes @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end |
#clear_changes_information ⇒ Object
43 44 45 46 |
# File 'lib/dinamo/model/dirty.rb', line 43 def clear_changes_information @previously_changed = ActiveSupport::HashWithIndifferentAccess.new @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end |
#clear_previous_attributes ⇒ Object
48 49 50 |
# File 'lib/dinamo/model/dirty.rb', line 48 def clear_previous_attributes @previously_changed = ActiveSupport::HashWithIndifferentAccess.new end |