Sha256: f6d0a978d06bb0098ce091c31dc43d09c86d2c7f63aab9a2ec300c9e6c4d8015
Contents?: true
Size: 990 Bytes
Versions: 4
Compression:
Stored size: 990 Bytes
Contents
# encoding: utf-8 module FiniteMachine # A class reponsible for building transition out of parsed states class TransitionBuilder include Threadable # The current state machine attr_threadsafe :machine attr_threadsafe :attributes # Initialize a TransitionBuilder # # @example # TransitionBuilder.new(machine, {}) # # @api public def initialize(machine, attributes = {}) @machine = machine @attributes = attributes end # Creates transitions for the states # # @example # transition_parser.call([:green, :yellow] => :red) # # @param [Hash[Symbol]] states # The states to extract # # @return [nil] # # @api public def call(states) FiniteMachine::StateParser.new(states).parse_states do |from, to| attributes.merge!(parsed_states: { from => to }) Transition.create(machine, attributes) end end end # TransitionBuilder end # FiniteMachine
Version data entries
4 entries across 4 versions & 1 rubygems