Class: Statefully::Diff::Changed
- Inherits:
-
Statefully::Diff
- Object
- Statefully::Diff
- Statefully::Diff::Changed
- Defined in:
- lib/statefully/diff.rb
Overview
Changed is a Statefully::Diff which contains changes between two successful States.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#added ⇒ Hash<Symbol, Object>
readonly
Hash of added properties and their values.
-
#changed ⇒ Hash<Symbol, Change>
readonly
Hash of changed properties and their current and previous values.
Instance Method Summary collapse
-
#created? ⇒ Boolean
Check if a Statefully::Diff resulted from creating a State.
-
#empty? ⇒ Boolean
Check if a Statefully::Diff is empty.
-
#initialize(added: {}, changed: {}) ⇒ Changed
constructor
Constructor for Changed.
-
#inspect ⇒ String
Human-readable representation of the Change for console inspection.
Methods inherited from Statefully::Diff
Constructor Details
#initialize(added: {}, changed: {}) ⇒ Changed
Constructor for Statefully::Diff::Changed
129 130 131 132 |
# File 'lib/statefully/diff.rb', line 129 def initialize(added: {}, changed: {}) @added = added.freeze @changed = changed.freeze end |
Instance Attribute Details
#added ⇒ Hash<Symbol, Object> (readonly)
Hash of added properties and their values
108 109 110 |
# File 'lib/statefully/diff.rb', line 108 def added @added end |
#changed ⇒ Hash<Symbol, Change> (readonly)
Hash of changed properties and their current and previous values
119 120 121 |
# File 'lib/statefully/diff.rb', line 119 def changed @changed end |
Instance Method Details
#created? ⇒ Boolean
Check if a Statefully::Diff resulted from creating a State
144 145 146 |
# File 'lib/statefully/diff.rb', line 144 def created? false end |
#empty? ⇒ Boolean
Check if a Statefully::Diff is empty
An empty Statefully::Diff means that there are no changes in properties between current and previous State.
158 159 160 |
# File 'lib/statefully/diff.rb', line 158 def empty? added.empty? && changed.empty? end |
#inspect ⇒ String
Human-readable representation of the Change for console inspection
169 170 171 172 173 |
# File 'lib/statefully/diff.rb', line 169 def inspect details = [self.class.name] details << inspect_details unless empty? "#<#{details.join(' ')}>" end |