Sha256: 856e8855912c6d5805b79b08b7deb4126ed23719f70d79accc896051ad578bd3

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

require 'haml-rails'
require 'effective_logging/engine'
require 'effective_logging/version'

module EffectiveLogging

  # The following are all valid config keys
  mattr_accessor :logs_table_name
  mattr_accessor :use_active_admin

  mattr_accessor :authorization_method
  mattr_accessor :layout
  mattr_accessor :additional_statuses

  mattr_accessor :emails_enabled
  mattr_accessor :user_logins_enabled

  def self.setup
    yield self
  end

  def self.authorized?(controller, action, resource)
    if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
      raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
    end
    true
  end

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

  def self.supressed?
    @supressed == true
  end

  def self.statuses
    @statuses ||= (Array(@@additional_statuses).map { |status| status.to_s.downcase } | ['info', 'success', 'error'])
  end

  def self.log_changes_status
    'logged change'.freeze
  end

  # This is set by the "set_log_changes_user" before_filter.
  def self.log_changes_user=(user)
    @log_changes_user = user
  end

  def self.log_changes_user
    @log_changes_user
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
effective_logging-1.5.7 lib/effective_logging.rb
effective_logging-1.5.6 lib/effective_logging.rb
effective_logging-1.5.5 lib/effective_logging.rb
effective_logging-1.5.4 lib/effective_logging.rb
effective_logging-1.5.3 lib/effective_logging.rb
effective_logging-1.5.2 lib/effective_logging.rb
effective_logging-1.5.1 lib/effective_logging.rb
effective_logging-1.5.0 lib/effective_logging.rb