aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/state_machine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/state_machine.rb')
-rw-r--r--activemodel/lib/active_model/state_machine.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/state_machine.rb b/activemodel/lib/active_model/state_machine.rb
index 89afc4abb6..bce90fd743 100644
--- a/activemodel/lib/active_model/state_machine.rb
+++ b/activemodel/lib/active_model/state_machine.rb
@@ -31,6 +31,12 @@ module ActiveModel
state_machines[name] ||= Machine.new(self, name)
block ? state_machines[name].update(options, &block) : state_machines[name]
end
+
+ def define_state_query_method(state_name)
+ name = "#{state_name}?"
+ undef_method(name) if method_defined?(name)
+ class_eval "def #{name}; current_state.to_s == %(#{state_name}) end"
+ end
end
def current_state(name = nil, new_state = nil, persist = false)