Class: PaperTrail::RelatedChanges::BuildChanges
- Inherits:
-
Object
- Object
- PaperTrail::RelatedChanges::BuildChanges
- Defined in:
- lib/paper_trail/related_changes/build_changes.rb
Instance Attribute Summary collapse
-
#item_id ⇒ Object
readonly
Returns the value of attribute item_id.
-
#item_type ⇒ Object
readonly
Returns the value of attribute item_type.
-
#model_type_children ⇒ Object
readonly
Returns the value of attribute model_type_children.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(results, model_type_children, item_type, item_id) ⇒ BuildChanges
constructor
A new instance of BuildChanges.
Constructor Details
#initialize(results, model_type_children, item_type, item_id) ⇒ BuildChanges
Returns a new instance of BuildChanges.
9 10 11 12 13 14 |
# File 'lib/paper_trail/related_changes/build_changes.rb', line 9 def initialize(results, model_type_children, item_type, item_id) @results = results @model_type_children = model_type_children @item_type = item_type @item_id = item_id end |
Instance Attribute Details
#item_id ⇒ Object (readonly)
Returns the value of attribute item_id.
4 5 6 |
# File 'lib/paper_trail/related_changes/build_changes.rb', line 4 def item_id @item_id end |
#item_type ⇒ Object (readonly)
Returns the value of attribute item_type.
4 5 6 |
# File 'lib/paper_trail/related_changes/build_changes.rb', line 4 def item_type @item_type end |
#model_type_children ⇒ Object (readonly)
Returns the value of attribute model_type_children.
4 5 6 |
# File 'lib/paper_trail/related_changes/build_changes.rb', line 4 def model_type_children @model_type_children end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/paper_trail/related_changes/build_changes.rb', line 4 def results @results end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/paper_trail/related_changes/build_changes.rb', line 16 def call changes = results.map do |root_version, versions, request_id| versions_serialized = versions_serialized(versions) root_change = change_with_root(request_id, root_version, versions_serialized) root_change.change.children = children_versions(versions_serialized).map(&:change) root_change.change end.compact remove_duplicate_changes(changes) end |