Module: Statum::InstanceMethods
- Defined in:
- lib/statum/instance_methods.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'lib/statum/instance_methods.rb', line 3
def method_missing(meth, *args)
if meth.to_s.end_with?('?') && (machine = find_machine_by_state(meth[0...-1]))
machine.current(self) == meth[0...-1].to_sym
elsif meth.to_s.end_with?('!') && (machine = find_machine_by_event(meth[0...-1]))
machine.fire!(self, meth[0...-1])
else
super
end
end
|
Instance Method Details
#respond_to_missing?(meth, *args) ⇒ Boolean
13
14
15
16
17
18
19
20
21
|
# File 'lib/statum/instance_methods.rb', line 13
def respond_to_missing?(meth, *args)
if meth.to_s.end_with?('?')
!find_machine_by_state(meth[0...-1]).nil?
elsif meth.to_s.end_with?('!')
!find_machine_by_event(meth[0...-1]).nil?
else
super
end
end
|