25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/state_methods/factory.rb', line 25
def declare(method_name)
this = self
::StateMethods::MethodUtils.define_class_method(@klass, method_name) do |*states, &block|
factory = this.factory_for(self)
states.each do |state|
factory.set(self, method_name, state, &block)
end
end
check(method_name, force=true)
state_accessor = @state_accessor
::StateMethods::MethodUtils.define_instance_method(@klass, method_name) do |*args|
state = send(state_accessor) || :*
factory = this.factory_for(self.class)
begin
factory.get(self, method_name, state, *args)
rescue Undefined
nil
end
end
end
|