app/models/concerns/order_state_config.rb
# Define methods to be executed AFTER the given even is complete
#   and the Order moves to a new state
Define methods to be executed AFTER the given even is complete
and the Order moves to a new state
Define methods to be executed AFTER the given even is complete and the Order moves to a new state
def event_callbacks(event, metadata={})
      case event
      when :reset, :review
        if confirmed
          update_attributes(confirmed: false)
        end
      when :confirm
        confirm
        items.each do |i|
          if i.event_permitted(:order)
            user_id = last_transition.user_id
            i.trigger!(:order, { order_id: id, user_id: user_id })
          end
        end
      when :complete_work
        request = metadata[:request]
        work_complete_notification(request)
      when :close
        close
      end
      if event != :close && !open
        reopen
      end
    end
def event_callbacks ( event , metadata = { } ) case event when :reset , :review if confirmed update_attributes ( confirmed : false ) end when :confirm confirm items . each do | i | if i . event_permitted ( :order ) user_id = last_transition . user_id i . trigger! ( :order , { order_id : id , user_id : user_id } ) end end when :complete_work request = metadata [ :request ] work_complete_notification ( request ) when :close close end if event != :close && ! open reopen end end
Define methods to be executed AFTER the given even is complete
and the Order moves to a new state
Define methods to be executed AFTER the given even is complete and the Order moves to a new state
# trigger :order for all applicable items # NOTE: :order event is common to both physical and digital items
event
<not_specific>
metadata
<not_specific>