Module: SparkApi::Models::Dirty
- Included in:
- Base
- Defined in:
- lib/spark_api/models/dirty.rb
Instance Method Summary collapse
- #changed ⇒ Object
- #changed? ⇒ Boolean
-
#changed_attributes ⇒ Object
hash with changed attributes and their original values.
- #changes ⇒ Object
-
#dirty_attributes ⇒ Object
hash with changed attributes and their new values.
- #previous_changes ⇒ Object
Instance Method Details
#changed ⇒ Object
9 10 11 |
# File 'lib/spark_api/models/dirty.rb', line 9 def changed changed_attributes.keys end |
#changed? ⇒ Boolean
5 6 7 |
# File 'lib/spark_api/models/dirty.rb', line 5 def changed? changed.any? end |
#changed_attributes ⇒ Object
hash with changed attributes and their original values
22 23 24 |
# File 'lib/spark_api/models/dirty.rb', line 22 def changed_attributes @changed_attributes ||= {} end |
#changes ⇒ Object
13 14 15 |
# File 'lib/spark_api/models/dirty.rb', line 13 def changes Hash[changed.map { |attr| [attr, attribute_change(attr)] }] end |
#dirty_attributes ⇒ Object
hash with changed attributes and their new values
27 28 29 |
# File 'lib/spark_api/models/dirty.rb', line 27 def dirty_attributes changed.inject({}) { |h, k| h[k] = attributes[k.to_s]; h } end |
#previous_changes ⇒ Object
17 18 19 |
# File 'lib/spark_api/models/dirty.rb', line 17 def previous_changes @previously_changed end |