lib/transitions/machine.rb in transitions-0.1.0 vs lib/transitions/machine.rb in transitions-0.1.1
- old
+ new
@@ -41,10 +41,11 @@
instance_eval(&block) if block
include_scopes if @auto_scopes && defined?(ActiveRecord::Base) && @klass < ActiveRecord::Base
self
end
+ # TODO Refactor me please?
def fire_event(event, record, persist, *args)
state_index[record.current_state].call_action(:exit, record)
begin
if new_state = @events[event].fire(record, nil, *args)
state_index[new_state].call_action(:enter, record)
@@ -68,20 +69,17 @@
raise e
end
end
end
- def states_for_select
- states.map { |st| [st.display_name, st.name.to_s] }
- end
-
def events_for(state)
events = @events.values.select { |event| event.transitions_from_state?(state) }
events.map! { |event| event.name }
end
def current_state_variable
- "@current_state"
+ # TODO Refactor me away.
+ :@current_state
end
private
def state(name, options = {})