lib/state_machine/machine.rb in state_machine-0.7.2 vs lib/state_machine/machine.rb in state_machine-0.7.3
- old
+ new
@@ -1114,10 +1114,16 @@
#
# By default, this is a no-op.
def reset(object)
end
+ # Generates the message to use when invalidating the given object after
+ # failing to transition on a specific event
+ def generate_message(name, values = [])
+ (@messages[name] || self.class.default_messages[name]) % values.map {|value| value.last}
+ end
+
# Runs a transaction, rolling back any changes if the yielded block fails.
#
# This is only applicable to integrations that involve databases. By
# default, this will not run any transactions, since the changes aren't
# taking place within the context of a database.
@@ -1203,11 +1209,11 @@
define_event_helpers
define_action_helpers if action
# Gets the state name for the current value
define_instance_method("#{attribute}_name") do |machine, object|
- machine.states.match(object).name
+ machine.states.match!(object).name
end
end
# Adds reader/writer methods for accessing the state attribute
def define_state_accessor
@@ -1341,14 +1347,8 @@
states << state = State.new(self, new_state)
end
state
end
- end
-
- # Generates the message to use when invalidating the given object after
- # failing to transition on a specific event
- def generate_message(name, values)
- (@messages[name] || self.class.default_messages[name]) % values.map {|value| value.last}
end
end
end