Class: Recorder::Revision
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Recorder::Revision
- Defined in:
- lib/recorder/revision.rb
Instance Method Summary collapse
-
#association_changeset(name) ⇒ Recorder::Changeset
Get changeset for an association.
-
#changed_associations ⇒ Array
Get names of item associations that has been changed.
-
#item_changeset ⇒ Recorder::Changeset
Get changeset for an item.
Instance Method Details
#association_changeset(name) ⇒ Recorder::Changeset
Get changeset for an association
46 47 48 49 50 51 |
# File 'lib/recorder/revision.rb', line 46 def association_changeset(name) association = self.item.send(name) # association = association.source if association.decorated? self.changeset_class(association).new(association, self.data['associations'].fetch(name.to_s).try(:fetch, 'changes')) end |
#changed_associations ⇒ Array
Get names of item associations that has been changed
39 40 41 |
# File 'lib/recorder/revision.rb', line 39 def changed_associations self.data['associations'].try(:keys) || [] end |
#item_changeset ⇒ Recorder::Changeset
Get changeset for an item
30 31 32 33 34 35 |
# File 'lib/recorder/revision.rb', line 30 def item_changeset return @item_changeset if defined?(@item_changeset) return nil if self.data['changes'].nil? @item_changeset ||= self.changeset_class(self.item).new(self.item, self.data['changes']) end |