class RailsAsyncMigrations::Workers
Constants
- ALLOWED
Attributes
called_worker[R]
Public Class Methods
new(called_worker)
click to toggle source
# File lib/rails_async_migrations/workers.rb, line 7 def initialize(called_worker) @called_worker = called_worker # :check_queue, :fire_migration ensure_worker_presence end
Public Instance Methods
perform(args = [])
click to toggle source
# File lib/rails_async_migrations/workers.rb, line 12 def perform(args = []) return unless ALLOWED.include? called_worker self.send called_worker, *args end
Private Instance Methods
check_queue(*args)
click to toggle source
# File lib/rails_async_migrations/workers.rb, line 19 def check_queue(*args) case workers_type when :sidekiq Workers::Sidekiq::CheckQueueWorker.perform_async(*args) when :delayed_job ::Delayed::Job.enqueue Migration::CheckQueue.new end end
ensure_worker_presence()
click to toggle source
# File lib/rails_async_migrations/workers.rb, line 41 def ensure_worker_presence case workers_type when :sidekiq unless defined? ::Sidekiq::Worker raise Error, 'Please install Sidekiq before to set it as worker adapter' end when :delayed_job unless defined? ::Delayed::Job raise Error, 'Please install Delayed::Job before to set it as worker adapter' end end end
fire_migration(*args)
click to toggle source
# File lib/rails_async_migrations/workers.rb, line 28 def fire_migration(*args) case workers_type when :sidekiq Workers::Sidekiq::FireMigrationWorker.perform_async(*args) when :delayed_job ::Delayed::Job.enqueue Migration::FireMigration.new(*args) end end
workers_type()
click to toggle source
# File lib/rails_async_migrations/workers.rb, line 37 def workers_type RailsAsyncMigrations.config.workers end