Module: T::Props::WeakConstructor

Extended by:
Sig
Includes:
Optional
Included in:
Constructor
Defined in:
lib/types/props/weak_constructor.rb

Overview

typed: false

Defined Under Namespace

Modules: DecoratorMethods

Constant Summary

Constants included from Helpers

Helpers::Private

Instance Method Summary collapse

Methods included from Sig

sig

Methods included from Helpers

#abstract!, #final!, #interface!, #mixes_in_class_methods, #requires_ancestor, #sealed!

Instance Method Details

#initialize(hash = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/types/props/weak_constructor.rb', line 10

def initialize(hash={})
  decorator = self.class.decorator

  hash_keys_matching_props = decorator.construct_props_with_defaults(self, hash) +
    decorator.construct_props_without_defaults(self, hash)

  if hash_keys_matching_props < hash.size
    raise ArgumentError.new("#{self.class}: Unrecognized properties: #{(hash.keys - decorator.props.keys).join(', ')}")
  end
end