Class: GlobalRegistry::Bindings::Worker
- Inherits:
-
Object
- Object
- GlobalRegistry::Bindings::Worker
- Includes:
- Sidekiq::Worker
- Defined in:
- lib/global_registry_bindings/worker.rb,
lib/global_registry_bindings/testing.rb
Direct Known Subclasses
GlobalRegistry::Bindings::Workers::DeleteEntityWorker, GlobalRegistry::Bindings::Workers::PullMdmIdWorker, GlobalRegistry::Bindings::Workers::PushEntityWorker, GlobalRegistry::Bindings::Workers::PushRelationshipWorker
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model = nil) ⇒ Worker
constructor
A new instance of Worker.
- #perform(model_class, id) ⇒ Object
Constructor Details
#initialize(model = nil) ⇒ Worker
Returns a new instance of Worker.
15 16 17 |
# File 'lib/global_registry_bindings/worker.rb', line 15 def initialize(model = nil) self.model = model end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
11 12 13 |
# File 'lib/global_registry_bindings/worker.rb', line 11 def model @model end |
Class Method Details
.perform_async(*args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/global_registry_bindings/worker.rb', line 24 def self.perform_async(*args) # Set global sidekiq_options worker = set(GlobalRegistry::Bindings.) if worker == self # sidekiq 4.x super(*args) else # sidekiq 5.x worker.perform_async(*args) end rescue Redis::BaseError => e case GlobalRegistry::Bindings.redis_error_action when :raise raise when :log ::Rollbar.error(e) if Module.const_defined? :Rollbar when :ignore nil end end |
.perform_async_real ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/global_registry_bindings/testing.rb', line 47 def self.perform_async(*args) # Set global sidekiq_options worker = set(GlobalRegistry::Bindings.) if worker == self # sidekiq 4.x super(*args) else # sidekiq 5.x worker.perform_async(*args) end rescue Redis::BaseError => e case GlobalRegistry::Bindings.redis_error_action when :raise raise when :log ::Rollbar.error(e) if Module.const_defined? :Rollbar when :ignore nil end end |
Instance Method Details
#perform(model_class, id) ⇒ Object
19 20 21 22 |
# File 'lib/global_registry_bindings/worker.rb', line 19 def perform(model_class, id) klass = model_class.is_a?(String) ? model_class.constantize : model_class self.model = klass.find(id) end |