Class: Workarea::Release::Changes
- Inherits:
-
Object
- Object
- Workarea::Release::Changes
- Defined in:
- app/models/workarea/release/changes.rb
Instance Attribute Summary collapse
-
#releasable ⇒ Object
readonly
Returns the value of attribute releasable.
Class Method Summary collapse
Instance Method Summary collapse
- #change_appears_in_earlier_release?(key, new_value) ⇒ Boolean
-
#initialize(releasable) ⇒ Changes
constructor
A new instance of Changes.
- #to_h ⇒ Object
- #to_originals_h ⇒ Object
- #track_change?(key, old_value, new_value) ⇒ Boolean
Constructor Details
#initialize(releasable) ⇒ Changes
Returns a new instance of Changes.
11 12 13 |
# File 'app/models/workarea/release/changes.rb', line 11 def initialize(releasable) @releasable = releasable end |
Instance Attribute Details
#releasable ⇒ Object (readonly)
Returns the value of attribute releasable.
4 5 6 |
# File 'app/models/workarea/release/changes.rb', line 4 def releasable @releasable end |
Class Method Details
Instance Method Details
#change_appears_in_earlier_release?(key, new_value) ⇒ Boolean
38 39 40 41 42 |
# File 'app/models/workarea/release/changes.rb', line 38 def change_appears_in_earlier_release?(key, new_value) Release.current.scheduled_before.flat_map(&:changesets).any? do |changeset| changeset.releasable == releasable && changeset.includes_change?(key, new_value) end end |
#to_h ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/models/workarea/release/changes.rb', line 15 def to_h releasable.changes.keys.inject({}) do |memo, key| old_value, new_value = *releasable.changes[key] memo[key] = new_value if track_change?(key, old_value, new_value) memo end end |
#to_originals_h ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/models/workarea/release/changes.rb', line 24 def to_originals_h releasable.changes.keys.inject({}) do |memo, key| old_value, new_value = *releasable.changes[key] memo[key] = old_value if track_change?(key, old_value, new_value) memo end end |
#track_change?(key, old_value, new_value) ⇒ Boolean
33 34 35 36 |
# File 'app/models/workarea/release/changes.rb', line 33 def track_change?(key, old_value, new_value) self.class.tracked_change?(key, old_value, new_value) && !change_appears_in_earlier_release?(key, new_value) end |