Class: ActionClient::SubmissionJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/action_client/submission_job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response


3
4
5
# File 'lib/action_client/submission_job.rb', line 3

def response
  @response
end

Class Method Details

.after_perform(only_status: nil, except_status: nil, **options, &block) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/action_client/submission_job.rb', line 5

def self.after_perform(only_status: nil, except_status: nil, **options, &block)
  if [only_status, except_status].all?(&:present?)
    raise ArgumentError, "either pass only_status: or except_status:, not both"
  end

  http_status_filter = if only_status.present?
    HttpStatusFilter.new(only_status)
  elsif except_status.present?
    HttpStatusFilter.new(except_status, inclusion: false)
  else
    HttpStatusFilter.new(nil)
  end

  options[:if] = -> { http_status_filter.include?(response.status) }

  super(**options, &block)
end

Instance Method Details

#perform(client_class_name, action_name, *arguments) ⇒ Object


23
24
25
26
27
28
29
# File 'lib/action_client/submission_job.rb', line 23

def perform(client_class_name, action_name, *arguments)
  client_class = client_class_name.constantize

  request = client_class.public_send(action_name, *arguments)

  @response = request.submit_now
end