Sha256: 266a6af62a810b5d27cf03d4bf9f5fb295f652d7731bf525b69f54cb45f07ac8

Contents?: true

Size: 575 Bytes

Versions: 7

Compression:

Stored size: 575 Bytes

Contents

# frozen_string_literal: true

require 'sidekiq'
require 'sidekiq-unique-jobs'

module GlobalRegistry #:nodoc:
  module Bindings #:nodoc:
    class Worker
      include Sidekiq::Worker

      attr_accessor :model
      delegate :global_registry_entity, to: :model
      delegate :global_registry_relationship, to: :model

      def initialize(model = nil)
        self.model = model
      end

      def perform(model_class, id)
        klass = model_class.is_a?(String) ? model_class.constantize : model_class
        self.model = klass.find(id)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
global-registry-bindings-0.1.6 lib/global_registry_bindings/worker.rb
global-registry-bindings-0.1.5 lib/global_registry_bindings/worker.rb
global-registry-bindings-0.1.4 lib/global_registry_bindings/worker.rb
global-registry-bindings-0.1.3 lib/global_registry_bindings/worker.rb
global-registry-bindings-0.1.2 lib/global_registry_bindings/worker.rb
global-registry-bindings-0.1.1 lib/global_registry_bindings/worker.rb
global-registry-bindings-0.1.0 lib/global_registry_bindings/worker.rb