Class: ExternalServices::ApiAction
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ExternalServices::ApiAction
show all
- Includes:
- Action
- Defined in:
- app/models/external_services/api_action.rb
Constant Summary
collapse
- MAX_ACTION_AGE =
ENV.fetch('EXTERNAL_SERVICES_MAX_ACTION_AGE') { '90' }.to_i.days
Constants included
from Action
ExternalServices::Action::QUEUE_PREFIX
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Action
#execute!, #kick_active_job, #prefixed_queue, #processed?, #set_processed!
Instance Attribute Details
#async=(value) ⇒ Object
7
8
9
|
# File 'app/models/external_services/api_action.rb', line 7
def async=(value)
@async = value
end
|
Class Method Details
.delete_old_processed ⇒ Object
26
27
28
|
# File 'app/models/external_services/api_action.rb', line 26
def self.delete_old_processed
processed.where(arel_table[:created_at].lt(MAX_ACTION_AGE.ago)).delete_all
end
|
Instance Method Details
#api_disabled? ⇒ Boolean
44
45
46
|
# File 'app/models/external_services/api_action.rb', line 44
def api_disabled?
initiator_class.send(:"#{self.class.to_s.demodulize.underscore}_api_disabled")
end
|
#change_external_id? ⇒ Boolean
36
37
38
|
# File 'app/models/external_services/api_action.rb', line 36
def change_external_id?
options['change_external_id']
end
|
#data ⇒ Object
52
53
54
|
# File 'app/models/external_services/api_action.rb', line 52
def data
!async && (method.to_sym == :delete) ? nil : super
end
|
#initiator_class ⇒ Object
30
31
32
33
34
|
# File 'app/models/external_services/api_action.rb', line 30
def initiator_class
initiator.try(:class) || initiator_type.constantize
end
|
#job_class ⇒ Object
40
41
42
|
# File 'app/models/external_services/api_action.rb', line 40
def job_class
"ExternalServices::#{self.class.to_s.demodulize}ApiJob".constantize
end
|
#signature ⇒ Object
48
49
50
|
# File 'app/models/external_services/api_action.rb', line 48
def signature
async ? super : calculate_signature
end
|