lib/reactor/workers/mailer_worker.rb in reactor-0.15.1 vs lib/reactor/workers/mailer_worker.rb in reactor-0.16.0

- old
+ new

@@ -4,35 +4,12 @@ =end module Reactor module Workers class MailerWorker - include Sidekiq::Worker + include Reactor::Workers::Configuration - CONFIG = [:source, :action, :async, :delay] - - class_attribute *CONFIG - - def self.configured? - CONFIG.all? {|field| field.present? } - end - - def self.perform_where_needed(data) - if delay > 0 - perform_in(delay, data) - elsif async - perform_async(data) - else - new.perform(data) - end - source - end - - def configured? - self.class.configured? - end - def perform(data) raise_unconfigured! unless configured? return :__perform_aborted__ unless should_perform? event = Reactor::Event.new(data) @@ -57,24 +34,8 @@ def deliverable?(msg) msg.respond_to?(:deliver_now) || msg.respond_to?(:deliver) end - def should_perform? - if Reactor.test_mode? - Reactor.test_mode_subscriber_enabled? source - else - true - end - end - - private - - def raise_unconfigured! - settings = Hash[CONFIG.map {|s| [s, self.class.send(s)] }] - raise UnconfiguredWorkerError.new( - "#{self.class.name} is not properly configured! Here are the settings: #{settings}" - ) - end end end end