Module: NotifiablyAudited::Audit::ClassMethods
- Defined in:
- lib/notifiably_audited/audit.rb
Instance Method Summary collapse
-
#as_user(user, &block) ⇒ Object
All audits made during the block called will be recorded as made by
user
. -
#audited_classes ⇒ Object
Returns the list of classes that are being audited.
- #setup_audit ⇒ Object
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.
33 34 35 36 37 38 |
# File 'lib/notifiably_audited/audit.rb', line 33 def as_user(user, &block) Thread.current[:audited_user] = user yield ensure Thread.current[:audited_user] = nil end |
#audited_classes ⇒ Object
Returns the list of classes that are being audited
26 27 28 |
# File 'lib/notifiably_audited/audit.rb', line 26 def audited_classes audited_class_names.map(&:constantize) end |
#setup_audit ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/notifiably_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 after_save :notify cattr_accessor :audited_class_names self.audited_class_names = Set.new attr_accessible :action, :audited_changes, :comment, :associated, :receiver_id, :checked, :meta,:title end |