Class: Argo::PropertyFactory

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/argo/property_factory.rb

Constant Summary collapse

TYPE_MAP =
{
  'array' => ArrayProperty,
  'boolean' => BooleanProperty,
  'integer' => IntegerProperty,
  'number' => NumberProperty,
  'object' => ObjectProperty,
  'string' => StringProperty
}

Instance Method Summary collapse

Constructor Details

#initialize(dereferencer, required_fields = []) ⇒ PropertyFactory

Returns a new instance of PropertyFactory.



25
26
27
28
# File 'lib/argo/property_factory.rb', line 25

def initialize(dereferencer, required_fields = [])
  @dereferencer = dereferencer
  @required_fields = required_fields
end

Instance Method Details

#build(body, name: nil) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/argo/property_factory.rb', line 32

def build(body, name: nil)
  class_for_type(body).new(
    constraints: constraints(body),
    description: body['description'],
    required: required?(name),
    **additional_properties(body)
  )
end