Module: Croods::Resource::JsonSchema::Definitions

Defined in:
lib/croods/resource/json_schema/definitions.rb

Class Method Summary collapse

Class Method Details

.attributes(resource) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/croods/resource/json_schema/definitions.rb', line 12

def attributes(resource)
  attributes = {}

  resource.definitions.each_value do |attribute|
    attributes[attribute.name] = Definition.schema(attribute)
  end

  attributes
end

.identity(resource) ⇒ Object



22
23
24
# File 'lib/croods/resource/json_schema/definitions.rb', line 22

def identity(resource)
  resource.ref(resource.identifier)
end

.schema(resource) ⇒ Object



8
9
10
# File 'lib/croods/resource/json_schema/definitions.rb', line 8

def schema(resource)
  attributes(resource).merge(identity: identity(resource))
end