module NRSER::Props::Immutable::Vector::ClassMethods
Methods mixed in at the class-level.
Public Instance Methods
alloc(*args)
click to toggle source
{Hamster::Vector} 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::Vector.alloc)
@return [Hamster::Vector]
The new instance, which will be of the propertied subclass of {Hamster::Vector}.
@raise [TypeError]
If the prop values of the new vector don't satisfy the prop types.
Calls superclass method
# File lib/nrser/props/immutable/vector.rb, line 74 def alloc *args super( *args ).tap do |new_instance| self.props( only_primary: true ).each_value do |prop| prop.check! new_instance[prop.index] end end end