lib/reactor/event.rb in reactor-2.0.0 vs lib/reactor/event.rb in reactor-2.0.1
- old
+ new
@@ -3,11 +3,12 @@
sidekiq_options queue: ENV['REACTOR_QUEUE'] || Sidekiq.default_worker_options['queue']
CONSOLE_CONFIRMATION_MESSAGE = <<-eos
It looks like you are on a production console. Only fire an event if you intend to trigger
- all of its subscribers. In order to proceed, you must pass `srsly: true` in the event data.'
+ all of its subscribers. In order to proceed, you must pass `srsly: true` in the event data. To
+ configure Reactor to ignore this validation, set `ENV['REACTOR_CONSOLE_ENABLED']` to a value.
eos
attr_accessor :__data__
def initialize(data = {})
@@ -58,10 +59,11 @@
def perform(name, data)
new.perform(name, data)
end
def publish(name, data = {})
- if defined?(Rails::Console) && ENV['RACK_ENV'] == 'production' && data[:srsly].blank?
+ if defined?(Rails::Console) && ENV['RACK_ENV'] == 'production' && data[:srsly].blank? &&
+ !ENV['REACTOR_CONSOLE_ENABLED']
raise ArgumentError.new(CONSOLE_CONFIRMATION_MESSAGE)
end
message = new(data.merge(event: name, uuid: SecureRandom.uuid))