Class: TrackChanges::Diff
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TrackChanges::Diff
- Defined in:
- app/models/track_changes/diff.rb
Instance Method Summary collapse
-
#changes ⇒ Object
Returns a hash of changes where the key is the field name and the value is an array of the from value and the to value.
-
#visible_changes ⇒ Object
Returns changes but only those where the string representation of the value has changed.
Instance Method Details
#changes ⇒ Object
Returns a hash of changes where the key is the field name and the value is an array of the from value and the to value
17 18 19 20 21 |
# File 'app/models/track_changes/diff.rb', line 17 def changes Hash[(from.keys + to.keys).collect do |key| [key, [from[key], to[key]]] end] end |
#visible_changes ⇒ Object
Returns changes but only those where the string representation of the value has changed
11 12 13 |
# File 'app/models/track_changes/diff.rb', line 11 def visible_changes changes.select {|key, (from, to)| (from.present? || to.present?) && (from.to_s != to.to_s) } end |