Class: ExternalServices::Service
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ExternalServices::Service
- Defined in:
- app/models/external_services/service.rb
Class Method Summary collapse
Instance Method Summary collapse
- #api_name ⇒ Object
- #on_subject_create(subj) ⇒ Object
- #on_subject_destroy(subj) ⇒ Object
- #on_subject_update(subj) ⇒ Object
Class Method Details
.to_sym ⇒ Object
15 16 17 |
# File 'app/models/external_services/service.rb', line 15 def self.to_sym to_s.demodulize.underscore.to_sym end |
Instance Method Details
#api_name ⇒ Object
35 36 37 |
# File 'app/models/external_services/service.rb', line 35 def api_name self.class.to_sym end |
#on_subject_create(subj) ⇒ Object
19 20 21 22 |
# File 'app/models/external_services/service.rb', line 19 def on_subject_create(subj) method = subj.send("#{api_name}_id").present? ? :put : :post subj.send("#{api_name}_api_action", method) end |
#on_subject_destroy(subj) ⇒ Object
31 32 33 |
# File 'app/models/external_services/service.rb', line 31 def on_subject_destroy(subj) subj.send("#{api_name}_api_action", :delete) end |
#on_subject_update(subj) ⇒ Object
24 25 26 27 28 29 |
# File 'app/models/external_services/service.rb', line 24 def on_subject_update(subj) method = subj.send("#{api_name}_id").present? ? :put : :post return true if (subj.respond_to?(:became_archived?) && subj.became_archived?) && method == :post subj.send("#{api_name}_api_action", method) end |