module NRSER::Props::Immutable::Hash::ClassMethods

Methods mixed in at the class-level.

Public Instance Methods

alloc(*args) click to toggle source

{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.

@param (see Hamster::Hash.alloc)

@return [Hamster::Hash]

The new instance, which will be of the propertied subclass of
{Hamster::Hash}.

@raise [TypeError]

If the prop values of the new vector don't satisfy the prop types.
Calls superclass method
# 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