Module: Recorder::Draper::DecoratorConcern
- Defined in:
- lib/recorder/draper/decorator_concern.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/recorder/draper/decorator_concern.rb', line 4 def self.included(base) base.decorates_association :item end |
Instance Method Details
#association_changeset(name) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/recorder/draper/decorator_concern.rb', line 18 def association_changeset(name) association = self.item.send(name) # association = association.source if association.decorated? self.changeset_klass(association).new(association, source.data['associations'].fetch(name.to_s).try(:fetch, 'changes')) end |
#changed_associations ⇒ Object
14 15 16 |
# File 'lib/recorder/draper/decorator_concern.rb', line 14 def changed_associations source.data['associations'].keys end |
#item_changeset ⇒ Object
8 9 10 11 12 |
# File 'lib/recorder/draper/decorator_concern.rb', line 8 def item_changeset return @item_changeset if defined?(@item_changeset) @item_changeset ||= self.changeset_klass(self.item.source).new(self.item, source.data['changes']) end |