Class: OAPI::Types::Object

Inherits:
BasicObject
Includes:
Properties
Defined in:
lib/oapi/types/object.rb

Class Method Summary collapse

Methods included from Properties

included, #initialize, #parse_property_value, #properties

Class Method Details

.parse(json) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/oapi/types/object.rb', line 9

def parse(json)
  new.tap do |obj|
    properties.each do |name, type|
      value = json[name.camelize]
      next if value.nil?

      value = type.parse(value) if type
      obj.send(name, value)
    end
  end
end