Open DougPuchalski opened 11 years ago
Here's how I hacked my instance method definition to defer to context methods when available, required on a per-method/per-state basis unfortunately.
def message
if (context_method = self.class.state_machines[:state].states[state].context_methods[__method__])
context_method.bind(self).call
else
'default message'
end
end
It feels like a method defined in a state context should override a method defined outside of it, i.e. a normal instance method of a class.
If I define the instance method, the same-named methods in the state context are never reached. If I do not define the instance method, then there is an exception if the method is called when in any state where it is not defined. Certainly not very DRY for a default case.