Sha256: 5d63718c33e12fb3fc024201c09530fe761fdd630c5660c26e1f3b66966fb5de

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require "global_registry_bindings/worker"
require "global_registry_bindings/entity/relationship_type_methods"
require "global_registry_bindings/entity/push_relationship_methods"

module GlobalRegistry # :nodoc:
  module Bindings # :nodoc:
    module Workers # :nodoc:
      class PushRelationshipWorker < GlobalRegistry::Bindings::Worker
        include GlobalRegistry::Bindings::Entity::RelationshipTypeMethods
        include GlobalRegistry::Bindings::Entity::PushRelationshipMethods
        sidekiq_options unique: :until_and_while_executing

        attr_accessor :type

        def initialize(model = nil, type = nil)
          super model
          self.type = type.to_sym if type
        end

        def perform(model_class, id, type)
          super model_class, id
          self.type = type.to_sym
          push_relationship_to_global_registry
        rescue ActiveRecord::RecordNotFound # rubocop:disable Lint/HandleExceptions
          # If the record was deleted after the job was created, swallow it
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
global-registry-bindings-0.7.2 lib/global_registry_bindings/workers/push_relationship_worker.rb
global-registry-bindings-0.7.1 lib/global_registry_bindings/workers/push_relationship_worker.rb
global-registry-bindings-0.7 lib/global_registry_bindings/workers/push_relationship_worker.rb
global-registry-bindings-0.6.3 lib/global_registry_bindings/workers/push_relationship_worker.rb