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?
Instance Attribute Details
#async=(value) ⇒ Object
9
10
11
|
# File 'app/models/external_services/api_action.rb', line 9
def async=(value)
@async = value
end
|
Class Method Details
.delete_old_processed ⇒ Object
28
29
30
|
# File 'app/models/external_services/api_action.rb', line 28
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
46
47
48
|
# File 'app/models/external_services/api_action.rb', line 46
def api_disabled?
initiator_class.send(:"#{self.class.to_s.demodulize.underscore}_api_disabled")
end
|
#change_external_id? ⇒ Boolean
38
39
40
|
# File 'app/models/external_services/api_action.rb', line 38
def change_external_id?
options['change_external_id']
end
|
#data ⇒ Object
54
55
56
|
# File 'app/models/external_services/api_action.rb', line 54
def data
!async && (method.to_sym == :delete) ? nil : super
end
|
#initiator_class ⇒ Object
32
33
34
35
36
|
# File 'app/models/external_services/api_action.rb', line 32
def initiator_class
initiator.try(:class) || initiator_type.constantize
end
|
#job_class ⇒ Object
42
43
44
|
# File 'app/models/external_services/api_action.rb', line 42
def job_class
"ExternalServices::#{self.class.to_s.demodulize}ApiJob".constantize
end
|
#set_processed! ⇒ Object
58
59
60
61
62
|
# File 'app/models/external_services/api_action.rb', line 58
def set_processed!
return true unless async
super
end
|
#signature ⇒ Object
50
51
52
|
# File 'app/models/external_services/api_action.rb', line 50
def signature
async ? super : calculate_signature
end
|