Class: StateMethods::Implementations::Functional
- Defined in:
- lib/state_methods/implementations/functional.rb
Instance Method Summary collapse
Methods inherited from Factory
#check, #declare, #factory_for, #init, #initialize
Constructor Details
This class inherits a constructor from StateMethods::Factory
Instance Method Details
#get(instance, method_name, state, *args) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/state_methods/implementations/functional.rb', line 9 def get(instance, method_name, state, *args) partition = instance.class._state_partition_for(@state_accessor) keys = partition.ancestors(state) if m = ::StateMethods::MethodUtils.find_defined(instance, method_name, *keys) instance.send(m, *args) else raise Undefined end end |
#set(klass, method_name, state, &block) ⇒ Object
5 6 7 |
# File 'lib/state_methods/implementations/functional.rb', line 5 def set(klass, method_name, state, &block) ::StateMethods::MethodUtils.define_instance_method(klass, [method_name, state], &block) end |