Module: HyperStore::InstanceMethods
- Defined in:
- lib/hyper-store/instance_methods.rb
Instance Method Summary collapse
Instance Method Details
#init_store ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hyper-store/instance_methods.rb', line 3 def init_store self.class.__instance_states.each do |instance_state| # If the scope is shared then we initialize at the class level next if instance_state[1][:scope] == :shared # TODO: Figure out exactly how we're going to handle passing in procs and blocks together # But for now...just do the proc first then the block # First initialize value from initializer Proc proc_value = initializer_value(instance_state[1][:initializer]) mutate.__send__(:"#{instance_state[0]}", proc_value) # Then call the block if a block is passed next unless instance_state[1][:block] block_value = instance_eval(&instance_state[1][:block]) mutate.__send__(:"#{instance_state[0]}", block_value) end end |
#mutate ⇒ Object
28 29 30 |
# File 'lib/hyper-store/instance_methods.rb', line 28 def mutate @mutate ||= self.class.singleton_class.__state_wrapper.instance_mutator_wrapper.new(self) end |
#state ⇒ Object
24 25 26 |
# File 'lib/hyper-store/instance_methods.rb', line 24 def state @state ||= self.class.singleton_class.__state_wrapper.instance_state_wrapper.new(self) end |