Class: ConcurrentPipeline::Changeset::CreateDelta

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

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



29
30
31
# File 'lib/concurrent_pipeline/changeset.rb', line 29

def attributes
  @attributes
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



29
30
31
# File 'lib/concurrent_pipeline/changeset.rb', line 29

def type
  @type
end

Class Method Details

.from_json(json) ⇒ Object



35
36
37
38
39
40
# File 'lib/concurrent_pipeline/changeset.rb', line 35

def self.from_json(json)
  new(
    type: json.fetch(:type),
    attributes: json.fetch(:attributes)
  )
end

Instance Method Details

#apply(store) ⇒ Object



30
31
32
33
# File 'lib/concurrent_pipeline/changeset.rb', line 30

def apply(store)
  store.create(type: type, attributes: attributes)
  Result.new(true)
end

#as_jsonObject



42
43
44
45
46
47
48
# File 'lib/concurrent_pipeline/changeset.rb', line 42

def as_json(...)
  {
    action: :create,
    type: type,
    attributes: attributes
  }
end