module Initializr

Public Class Methods

instantiate(obj, schemas) click to toggle source
# File lib/initializr.rb, line 3
def self.instantiate obj, schemas
  if schemas.is_a? Hash
    children = schemas.keys.map do |key|
      value = schemas[key].instantiate(obj[key])
      Hash[key, value]
    end.reduce({}, &:merge)
    obj.merge(children)
  else
    schemas.instantiate(obj)
  end
end