lib/finite_machine/dsl.rb in finite_machine-0.6.1 vs lib/finite_machine/dsl.rb in finite_machine-0.7.0

- old
+ new

@@ -71,22 +71,22 @@ unless defer machine.state = state machine.initial_state = state end event = proc { event name, from: FiniteMachine::DEFAULT_STATE, to: state } - machine.events.call(&event) + machine.events_dsl.call(&event) end # Attach state machine to an object # # This allows state machine to initiate events in the context # of a particular object # # @example # FiniteMachine.define do # target :red - # end + # end # # @param [Object] object # # @return [FiniteMachine::StateMachine] # @@ -115,11 +115,11 @@ # # @return [FiniteMachine::StateMachine] # # @api public def events(&block) - machine.events.call(&block) + machine.events_dsl.call(&block) end # Define state machine callbacks # # @api public @@ -182,19 +182,19 @@ # @return [Transition] # # @api public def event(name, attrs = {}, &block) sync_exclusive do - _transition = Transition.new(machine, attrs.merge!(name: name)) - _transition.define - _transition.define_state_methods - _transition.define_event + attributes = attrs.merge!(name: name) + FiniteMachine::StateParser.new(attrs).parse_states do |from, to| + attributes.merge!(parsed_states: { from => to }) + Transition.create(machine, attributes) + end end end end # EventsDSL class ErrorsDSL < GenericDSL - # Add error handler # # @param [Array] exceptions # # @example