module NRSER::Props::Immutable::HashVariable
Mix-in to store property values in an immutable {Hamster::Hash} instance in an instance variable.
This is basically an improvement of how the original props implementation worked.
Constants
- INSTANCE_VARIABLE_STORAGE
- KEY_STORAGE
Public Class Methods
Public Instance Methods
initialize_props(values = {})
click to toggle source
Instantiate a new `NRSER::Props::Immutable::Vector`.
# File lib/nrser/props/immutable/hash_variable.rb, line 54 def initialize_props values = {} prop_values = {} self.class.metadata.each_primary_prop_value_from( values ) { |prop, value| prop_values[prop.name] = value } instance_variable_set self.class.metadata.storage.var_name, Hamster::Hash.new( values ) # Check additional type invariants self.class.invariants.each do |type| type.check self end end