Module: NRSER::Props::Immutable::Hash::ClassMethods
- Defined in:
- lib/nrser/props/immutable/hash.rb
Overview
Methods mixed in at the class-level.
Instance Method Summary collapse
-
#alloc(*args) ⇒ Hamster::Hash
Hamster::Hash uses ‘.alloc` to quickly create derived instances when it knows the instance variables.
Instance Method Details
#alloc(*args) ⇒ Hamster::Hash
Hamster::Hash uses ‘.alloc` to quickly create derived instances when it knows the instance variables. We need to hook into that to check the prop types.
74 75 76 77 78 79 80 |
# File 'lib/nrser/props/immutable/hash.rb', line 74 def alloc *args super( *args ).tap do |new_instance| self.props( only_primary: true ).values.each do |prop| prop.check! new_instance[prop.name] end end end |