Module: Audited::Audit::ClassMethods

Defined in:
lib/audited/audit.rb

Instance Method Summary collapse

Instance Method Details

#as_user(user, &block) ⇒ Object

All audits made during the block called will be recorded as made by user. This method is hopefully threadsafe, making it ideal for background operations that require audit information.



28
29
30
31
32
33
# File 'lib/audited/audit.rb', line 28

def as_user(user, &block)
  Thread.current[:audited_user] = user
  yield
ensure
  Thread.current[:audited_user] = nil
end

#audited_classesObject

Returns the list of classes that are being audited



21
22
23
# File 'lib/audited/audit.rb', line 21

def audited_classes
  audited_class_names.map(&:constantize)
end

#setup_auditObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/audited/audit.rb', line 9

def setup_audit
  belongs_to :auditable,  :polymorphic => true
  belongs_to :user,       :polymorphic => true
  belongs_to :associated, :polymorphic => true

  before_create :set_version_number, :set_audit_user, :set_request_uuid

  cattr_accessor :audited_class_names
  self.audited_class_names = Set.new
end