module Hickory::Rails
Public Instance Methods
config()
click to toggle source
# File lib/hickory/rails.rb, line 29 def config application.config.hickory end
remove_existing_log_subscriptions()
click to toggle source
# File lib/hickory/rails.rb, line 33 def remove_existing_log_subscriptions ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber| case subscriber when ActionView::LogSubscriber unsubscribe(:action_view, subscriber) when ActionController::LogSubscriber unsubscribe(:action_controller, subscriber) when ActionMailer::LogSubscriber unsubscribe(:action_mailer, subscriber) end end end
setup(app)
click to toggle source
# File lib/hickory/rails.rb, line 19 def setup(app) self.application = app self.ignore_if = config.ignore_if remove_existing_log_subscriptions Hickory::LogSubscribers::ActionController.attach_to :action_controller Hickory::LogSubscribers::ActionMailer.attach_to :action_mailer Hickory::LogSubscribers::ActiveJob.attach_to :active_job end
unsubscribe(component, subscriber)
click to toggle source
# File lib/hickory/rails.rb, line 46 def unsubscribe(component, subscriber) events = subscriber.public_methods(false).reject { |method| method.to_s == 'call' } events.each do |event| ActiveSupport::Notifications.notifier.listeners_for("#{event}.#{component}").each do |listener| if listener.instance_variable_get('@delegate') == subscriber ActiveSupport::Notifications.unsubscribe listener end end end end