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
26 27 28 |
# File 'lib/hickory/rails.rb', line 26 def config application.config.hickory end |
.remove_existing_log_subscriptions ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hickory/rails.rb', line 30 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) when ActiveJob::Logging::LogSubscriber unsubscribe(:active_job, subscriber) end end end |
.setup(app) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/hickory/rails.rb', line 16 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
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hickory/rails.rb', line 45 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 |