Module: EffectiveLogging

Defined in:
lib/effective_logging.rb,
lib/effective_logging/engine.rb,
lib/effective_logging/version.rb,
lib/effective_logging/user_logger.rb,
lib/effective_logging/email_logger.rb,
lib/effective_logging/log_page_views.rb,
lib/effective_logging/set_current_user.rb,
lib/effective_logging/active_record_logger.rb,
lib/generators/effective_logging/install_generator.rb

Defined Under Namespace

Modules: Generators, LogPageViews, SetCurrentUser Classes: ActiveRecordLogger, EmailLogger, Engine, UserLogger

Constant Summary collapse

VERSION =
'2.0.3'.freeze

Class Method Summary collapse

Class Method Details

.authorize!(controller, action, resource) ⇒ Object



35
36
37
# File 'lib/effective_logging.rb', line 35

def self.authorize!(controller, action, resource)
  raise Effective::AccessDenied unless authorized?(controller, action, resource)
end

.authorized?(controller, action, resource) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/effective_logging.rb', line 22

def self.authorized?(controller, action, resource)
  @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact

  return !!authorization_method unless authorization_method.respond_to?(:call)
  controller = controller.controller if controller.respond_to?(:controller)

  begin
    !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
  rescue *@_exceptions
    false
  end
end

.current_userObject



63
64
65
# File 'lib/effective_logging.rb', line 63

def self.current_user
  @effective_logging_current_user
end

.current_user=(user) ⇒ Object

This is set by the "set_effective_logging_current_user" before_filter.



59
60
61
# File 'lib/effective_logging.rb', line 59

def self.current_user=(user)
  @effective_logging_current_user = user
end

.log_changes_statusObject



54
55
56
# File 'lib/effective_logging.rb', line 54

def self.log_changes_status
  'change'.freeze
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



18
19
20
# File 'lib/effective_logging.rb', line 18

def self.setup
  yield self
end

.statusesObject



47
48
49
50
51
52
# File 'lib/effective_logging.rb', line 47

def self.statuses
  @statuses ||= (
    Array(@@additional_statuses).map { |status| status.to_s.downcase } |  # union
    ['info', 'success', 'error', 'view', log_changes_status, ('email' if email_enabled), ('sign_in' if ), ('sign_out' if sign_out_enabled)].compact
  )
end

.supressed(&block) ⇒ Object



39
40
41
# File 'lib/effective_logging.rb', line 39

def self.supressed(&block)
  @supressed = true; yield; @supressed = false
end

.supressed?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/effective_logging.rb', line 43

def self.supressed?
  @supressed == true
end