Module: T::Props::Constructor
Overview
typed: false
Constant Summary
Constants included from Helpers
Instance Method Summary collapse
Methods included from Helpers
#abstract!, #final!, #interface!, #mixes_in_class_methods
Instance Method Details
#initialize(hash = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/types/props/constructor.rb', line 7 def initialize(hash={}) decorator = self.class.decorator decorator.props.each do |prop, rules| # It's important to explicitly compare against `true` here; the value can also be :existing or # :on_load (which are truthy) but we don't want to treat those as optional in this context. if T::Props::Utils.required_prop?(rules) && !decorator.has_default?(rules) && !hash.key?(prop) raise ArgumentError.new("Missing required prop `#{prop}` for class `#{self.class}`") end end super end |