Sha256: 5e5b59de16f7ec84029f446fe79b6aa4f14a5e981a801167c3e51ed2e5157cf5

Contents?: true

Size: 745 Bytes

Versions: 9

Compression:

Stored size: 745 Bytes

Contents

require 'interactor'

module DiscoApp
  module Flow
    class CreateAction

      include Interactor

      delegate :shop, :action_id, :action_run_id, :properties, to: :context
      delegate :action, to: :context

      def call
        create_action
        enqueue_process_action_job
      end

      private

        def create_action
          context.action = shop.flow_actions.create!(
            action_id: action_id,
            action_run_id: action_run_id,
            properties: properties
          )
        rescue ActiveRecord::RecordNotUnique, PG::UniqueViolation
          context.fail!
        end

        def enqueue_process_action_job
          ProcessActionJob.perform_later(shop, action)
        end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/services/disco_app/flow/create_action.rb
disco_app-0.17.0 app/services/disco_app/flow/create_action.rb
disco_app-0.18.0 app/services/disco_app/flow/create_action.rb
disco_app-0.18.2 app/services/disco_app/flow/create_action.rb
disco_app-0.18.3 app/services/disco_app/flow/create_action.rb
disco_app-0.18.6 app/services/disco_app/flow/create_action.rb
disco_app-0.16.1 app/services/disco_app/flow/create_action.rb
disco_app-0.18.4 app/services/disco_app/flow/create_action.rb
disco_app-0.18.1 app/services/disco_app/flow/create_action.rb