Class: Ea::Spa::Shard

Inherits:
Struct
  • Object
show all
Defined in:
lib/ea/spa/shard.rb

Overview

Per-entity detail payload. Plain Ruby value object (not a lutaml-model type) because the payload is an arbitrary JSON blob whose shape depends on the model element's kind — we don't want the framework's hash-type cast getting in the way.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



9
10
11
# File 'lib/ea/spa/shard.rb', line 9

def id
  @id
end

#kindObject

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



9
10
11
# File 'lib/ea/spa/shard.rb', line 9

def kind
  @kind
end

#payloadObject

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



9
10
11
# File 'lib/ea/spa/shard.rb', line 9

def payload
  @payload
end

Instance Method Details

#to_hObject



10
11
12
# File 'lib/ea/spa/shard.rb', line 10

def to_h
  { "id" => id, "kind" => kind, "payload" => payload }
end

#to_json(*args) ⇒ Object



14
15
16
# File 'lib/ea/spa/shard.rb', line 14

def to_json(*args)
  JSON.generate(to_h, *args)
end