Class: ConcurrentPipeline::Changeset::InitialDelta
- Inherits:
-
Struct
- Object
- Struct
- ConcurrentPipeline::Changeset::InitialDelta
- Defined in:
- lib/concurrent_pipeline/changeset.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#dup ⇒ Object
Returns the value of attribute dup.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
9 10 11 |
# File 'lib/concurrent_pipeline/changeset.rb', line 9 def data @data end |
#dup ⇒ Object
Returns the value of attribute dup
9 10 11 |
# File 'lib/concurrent_pipeline/changeset.rb', line 9 def dup @dup end |
Class Method Details
.from_json(json) ⇒ Object
17 18 19 |
# File 'lib/concurrent_pipeline/changeset.rb', line 17 def self.from_json(json) new(data: json.fetch(:delta), dup: true) end |
Instance Method Details
#apply(store) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/concurrent_pipeline/changeset.rb', line 10 def apply(store) # We fully dup the data to avoid mutating the input dup_data = YAML.unsafe_load(data.to_yaml) store.set(dup_data) Result.new(true) end |
#as_json ⇒ Object
21 22 23 24 25 26 |
# File 'lib/concurrent_pipeline/changeset.rb', line 21 def as_json(...) { action: :initial, delta: data } end |