Sha256: 1029b06b36c03af8dd3d8a20bf8bc9bb012f8843019453e5c99afa5b20a7ee07

Contents?: true

Size: 443 Bytes

Versions: 2

Compression:

Stored size: 443 Bytes

Contents

# frozen_string_literal: true

class OAPI::Types::Object
  using OAPI::Monkey

  include OAPI::Properties

  class << self
    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 value.is_a?(Hash) || (value.is_a?(Array) && type)
          obj.send(name, value)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oapi-0.1.1 lib/oapi/types/object.rb
oapi-0.1.0 lib/oapi/types/object.rb