Module: Highlight::Integrations::Rails

Defined in:
lib/highlight.rb

Defined Under Namespace

Modules: ClassMethods, ViewHelpers

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



252
253
254
255
256
257
258
259
260
261
# File 'lib/highlight.rb', line 252

def self.included(base)
  base.extend(ClassMethods)

  if base.respond_to?(:helper_method)
    base.helper_method(:highlight_headers)
    base.helper(ViewHelpers)
  end

  base.around_action(:with_highlight_context)
end

Instance Method Details

#with_highlight_context(&block) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
# File 'lib/highlight.rb', line 263

def with_highlight_context(&block)
  return yield unless H.initialized?

  set_highlight_headers
  H.instance.trace(
    highlight_headers.session_id,
    highlight_headers.request_id,
    name: "#{request.method.upcase} #{request.path}",
    &block
  )
end