Constructor Details

Creates a new collection of transitions that can be run in parallel. Each transition must be for a different attribute.

Configuration options:

:actions - Whether to run the action configured for each transition

:after - Whether to run after callbacks

:transaction - Whether to wrap transitions within a transaction

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

# File 'lib/state_machines/transition_collection.rb', line 22definitialize(transitions=[],options={})super(transitions)# Determine the validity of the transitions as a whole
@valid=all?reject!{|transition|!transition}attributes=map{|transition|transition.attribute}.uniqfailArgumentError,'Cannot perform multiple transitions in parallel for the same state machine attribute'ifattributes.length!=lengthoptions.assert_valid_keys(:actions,:after,:use_transactions)options={actions:true,after:true,use_transactions:true}.merge(options)@skip_actions=!options[:actions]@skip_after=!options[:after]@use_transactions=options[:use_transactions]end