class Initializr::HashOf

Public Class Methods

new(schema) click to toggle source
# File lib/initializr/hash_of.rb, line 4
def initialize schema
  @schema = schema
end

Public Instance Methods

instantiate(obj) click to toggle source
# File lib/initializr/hash_of.rb, line 8
def instantiate obj
  Hash(obj).keys.map do |key|
    Hash[key, @schema.instantiate(obj[key])]
  end.reduce({}, &:merge)
end