Class: ConcurrentPipeline::Changeset::InitialDelta

Inherits:
Struct
  • Object
show all
Defined in:
lib/concurrent_pipeline/changeset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



9
10
11
# File 'lib/concurrent_pipeline/changeset.rb', line 9

def data
  @data
end

#dupObject

Returns the value of attribute dup

Returns:

  • (Object)

    the current value of 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_jsonObject



21
22
23
24
25
26
# File 'lib/concurrent_pipeline/changeset.rb', line 21

def as_json(...)
  {
    action: :initial,
    delta: data
  }
end