Method: Attributor::Hash.construct

Defined in:
lib/attributor/types/hash.rb

.construct(constructor_block, **options) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/attributor/types/hash.rb', line 171

def self.construct(constructor_block, **options)
  return self if constructor_block.nil?

  unless @concrete
    return of(key: key_type, value: value_type)
           .construct(constructor_block, **options)
  end

  if options[:case_insensitive_load] && !(key_type <= String)
    raise Attributor::AttributorException, ":case_insensitive_load may not be used with keys of type #{key_type.name}"
  end

  keys(**options, &constructor_block)
  self
end