Module: GOBL::Extensions::Schema::ObjectHelper::ClassMethods

Included in:
Schema::Object
Defined in:
lib/gobl/extensions/schema/object_helper.rb

Instance Method Summary collapse

Instance Method Details

#embed(struct) ⇒ Object

Embeds the given GOBL struct in a new object injecting the proper Schema ID.

Returns:

  • (Object)

    the object embedding the given struct



40
41
42
43
44
# File 'lib/gobl/extensions/schema/object_helper.rb', line 40

def embed(struct)
  new struct.as_json.merge(
    '$schema' => struct.class::SCHEMA_ID
  )
end