Module: TinyDyno::Changeable
- Extended by:
- ActiveSupport::Concern
- Included in:
- DocumentComposition
- Defined in:
- lib/tiny_dyno/changeable.rb
Overview
Defines behaviour for dirty tracking.
Instance Method Summary collapse
-
#changed ⇒ Array<String>
Get the changed attributes for the document.
-
#changed_attributes ⇒ Hash<String, Object>
Get the attribute changes.
-
#changes ⇒ Hash<String, Array<Object, Object> ] The changes.
Get all the changes for the document.
Instance Method Details
#changed ⇒ Array<String>
Get the changed attributes for the document.
17 18 19 |
# File 'lib/tiny_dyno/changeable.rb', line 17 def changed changed_attributes.keys.select { |attr| attribute_change(attr) } end |
#changed_attributes ⇒ Hash<String, Object>
Get the attribute changes.
29 30 31 |
# File 'lib/tiny_dyno/changeable.rb', line 29 def changed_attributes @changed_attributes ||= {} end |
#changes ⇒ Hash<String, Array<Object, Object> ] The changes.
Get all the changes for the document.
41 42 43 44 45 46 47 48 49 |
# File 'lib/tiny_dyno/changeable.rb', line 41 def changes _changes = {} changed.each do |attr| next if attr.nil? change = attribute_change(attr) _changes[attr] = change end _changes end |