Module: Hickory::Rails
- Defined in:
- lib/hickory/rails.rb,
lib/hickory/rails/railtie.rb
Defined Under Namespace
Classes: Railtie
Class Method Summary collapse
- .config ⇒ Object
- .remove_existing_log_subscriptions ⇒ Object
- .setup(app) ⇒ Object
- .unsubscribe(component, subscriber) ⇒ Object
Class Method Details
.config ⇒ Object
29 30 31 |
# File 'lib/hickory/rails.rb', line 29 def config application.config.hickory end |
.remove_existing_log_subscriptions ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# 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) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# 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) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# 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 |