module NRSER::Props::Immutable::InstanceVariables

Mix-in to store property values in instance variables of the same name.

Constants

STORAGE

Public Class Methods

included(base) click to toggle source

Class Methods

# File lib/nrser/props/immutable/instance_variables.rb, line 24
def self.included base
  base.include NRSER::Props
  base.metadata.storage STORAGE
  base.metadata.freeze
end

Public Instance Methods

initialize_props(values = {}) click to toggle source

Since the {NRSER::Props::Immutable::InstanceVariables} mix-in does not need to tap into the initialize chain,

# File lib/nrser/props/immutable/instance_variables.rb, line 37
def initialize_props values = {}
  self.class.metadata.each_primary_prop_value_from( values ) { |prop, value|
    instance_variable_set "@#{ prop.name }", value
  }
  
  # Check additional type invariants
  self.class.invariants.each do |type|
    type.check self
  end
end