Class: DeltaCore::DeltaResult
- Inherits:
-
Object
- Object
- DeltaCore::DeltaResult
- Defined in:
- lib/delta_core/delta_result.rb
Instance Attribute Summary collapse
-
#added ⇒ Object
readonly
Returns the value of attribute added.
-
#modified ⇒ Object
readonly
Returns the value of attribute modified.
-
#removed ⇒ Object
readonly
Returns the value of attribute removed.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(added: [], removed: [], modified: []) ⇒ DeltaResult
constructor
A new instance of DeltaResult.
- #merge(other) ⇒ Object
- #render(renderer) ⇒ Object
Constructor Details
#initialize(added: [], removed: [], modified: []) ⇒ DeltaResult
Returns a new instance of DeltaResult.
7 8 9 10 11 12 |
# File 'lib/delta_core/delta_result.rb', line 7 def initialize(added: [], removed: [], modified: []) @added = Array(added).freeze @removed = Array(removed).freeze @modified = Array(modified).freeze freeze end |
Instance Attribute Details
#added ⇒ Object (readonly)
Returns the value of attribute added.
5 6 7 |
# File 'lib/delta_core/delta_result.rb', line 5 def added @added end |
#modified ⇒ Object (readonly)
Returns the value of attribute modified.
5 6 7 |
# File 'lib/delta_core/delta_result.rb', line 5 def modified @modified end |
#removed ⇒ Object (readonly)
Returns the value of attribute removed.
5 6 7 |
# File 'lib/delta_core/delta_result.rb', line 5 def removed @removed end |
Instance Method Details
#empty? ⇒ Boolean
14 15 16 |
# File 'lib/delta_core/delta_result.rb', line 14 def empty? added.empty? && removed.empty? && modified.empty? end |
#merge(other) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/delta_core/delta_result.rb', line 18 def merge(other) self.class.new( added: added + other.added, removed: removed + other.removed, modified: modified + other.modified ) end |
#render(renderer) ⇒ Object
26 27 28 |
# File 'lib/delta_core/delta_result.rb', line 26 def render(renderer) renderer.call(self) end |