Module: EffectiveLogging::LogPageViews::InstanceMethods

Defined in:
lib/effective_logging/log_page_views.rb

Instance Method Summary collapse

Instance Method Details

#effective_logging_log_page_viewObject


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/effective_logging/log_page_views.rb', line 37

def effective_logging_log_page_view
  return if EffectiveLogging.supressed?
  return if @_effective_logging_skip_log_page_view == true
  return if (self.class.log_page_views_opts[:skip_namespace] || []).include?(self.class.ancestors.first)

  user = EffectiveLogging.current_user || (current_user if respond_to?(:current_user))

  if self.class.log_page_views_opts[:details] == false
    ::EffectiveLogger.view("#{request.request_method} #{request.path}", user: user)
  else
    ::EffectiveLogger.view(
      "#{request.request_method} #{request.path}",
      user: user,
      format: (request.format.to_s == 'text/html' ? nil : request.format.to_s),
      params: request.filtered_parameters.reject { |k, v| (k == 'controller' || k == 'action') },
      request: request
    )
  end
end

#skip_log_page_viewObject


57
58
59
# File 'lib/effective_logging/log_page_views.rb', line 57

def skip_log_page_view
  @_effective_logging_skip_log_page_view = true
end

#skip_log_page_viewsObject


61
62
63
# File 'lib/effective_logging/log_page_views.rb', line 61

def skip_log_page_views
  @_effective_logging_skip_log_page_view = true
end