Module: Marginalia::ActionControllerInstrumentation

Defined in:
lib/marginalia.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(instrumented_class) ⇒ Object



97
98
99
100
101
102
103
104
105
# File 'lib/marginalia.rb', line 97

def self.included(instrumented_class)
  instrumented_class.class_eval do
    if respond_to?(:around_action)
      around_action :record_query_comment
    else
      around_filter :record_query_comment
    end
  end
end

Instance Method Details

#record_query_commentObject



107
108
109
110
111
112
# File 'lib/marginalia.rb', line 107

def record_query_comment
  Marginalia::Comment.update!(self)
  yield
ensure
  Marginalia::Comment.clear!
end