lib/aasm/supporting_classes/event.rb
def _fire(obj, test, to_state=nil, *args)
        if @transitions.map(&:from).any?
          transitions = @transitions.select { |t| t.from == obj.aasm_current_state }
          return nil if transitions.size == 0
        else
          transitions = @transitions
        end

        result = test ? false : nil
        transitions.each do |transition|
          next if to_state and !Array(transition.to).include?(to_state)
          if transition.perform(obj, *args)
            if test
              result = true
            else
              result = to_state || Array(transition.to).first
              transition.execute(obj, *args)
            end

            break
          end
        end
        result
      end
# Execute if test? == false, otherwise return true/false depending on whether it would fire
Execute if test. == false, otherwise return true/false depending on whether it would fire
Execute if test . == false otherwise return true / false depending on whether it would fire
def _fire(obj, test, to_state=nil, *args)
        if @transitions.map(&:from).any?
          transitions = @transitions.select { |t| t.from == obj.aasm_current_state }
          return nil if transitions.size == 0
        else
          transitions = @transitions
        end
        result = test ? false : nil
        transitions.each do |transition|
          next if to_state and !Array(transition.to).include?(to_state)
          if transition.perform(obj, *args)
            if test
              result = true
            else
              result = to_state || Array(transition.to).first
              transition.execute(obj, *args)
            end
            break
          end
        end
        result
      end
def _fire ( obj , test , to_state = nil , * args ) if @transitions . map ( & :from ) . any? transitions = @transitions . select { | t | t . from == obj . aasm_current_state } return nil if transitions . size == 0 else transitions = @transitions end result = test ? false : nil transitions . each do | transition | next if to_state and ! Array ( transition . to ) . include? ( to_state ) if transition . perform ( obj , * args ) if test result = true else result = to_state || Array ( transition . to ) . first transition . execute ( obj , * args ) end break end end result end
Execute if test?
Execute if test?
obj
test
to_state
args