app/models/external_services/service.rb in external_services-0.5.2 vs app/models/external_services/service.rb in external_services-0.5.4

- old
+ new

@@ -1,15 +1,17 @@ +# frozen_string_literal: true + module ExternalServices class Service < ::ActiveRecord::Base self.table_name = :external_services belongs_to :subject, polymorphic: true - serialize :extra_data, JSON + serialize :extra_data, coder: JSON after_update :on_first_sync, if: proc { # Rails 5.1+ support - (respond_to?(:saved_change_to_external_id?) ? saved_change_to_external_id? : external_id_changed? ) && - (respond_to?(:external_id_before_last_save) ? external_id_before_last_save : external_id_was).nil? + (respond_to?(:saved_change_to_external_id?) ? saved_change_to_external_id? : external_id_changed?) && + (respond_to?(:external_id_before_last_save) ? external_id_before_last_save : external_id_was).nil? } def self.to_sym to_s.demodulize.underscore.to_sym end @@ -20,9 +22,10 @@ end 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 def on_subject_destroy(subj) subj.send("#{api_name}_api_action", :delete)