Class: ABBYY::Cloud::Struct

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/abbyy/cloud/struct.rb

Class Method Summary collapse

Class Method Details

.new(data) ⇒ Object Also known as: []



3
4
5
6
7
8
9
10
# File 'lib/abbyy/cloud/struct.rb', line 3

def new(data)
  default = schema.keys.each_with_object({}) { |key, hash| hash[key] = nil }
  actual  = data.to_hash.each_with_object({}) do |(key, val), hash|
    hash[key.to_sym] = val
  end

  super default.merge(actual)
end