Class: AuditLog
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- AuditLog
- Defined in:
- lib/sequel/plugins/auditer.rb
Instance Method Summary collapse
- #audit_additional_info ⇒ Object
- #audit_owner ⇒ Object
-
#audit_user ⇒ Object
Obtains the ‘current_user` based upon the `:auditer_current_user_method’ value set in the audited model, either via defaults or via :user_method config options.
- #before_validation ⇒ Object
Instance Method Details
#audit_additional_info ⇒ Object
52 53 54 55 56 57 |
# File 'lib/sequel/plugins/auditer.rb', line 52 def audit_additional_info m = Kernel.const_get(associated_type) m.send(m.auditer_additional_info_method) || send(m.auditer_additional_info_method) rescue StandardError nil end |
#audit_owner ⇒ Object
59 60 61 62 |
# File 'lib/sequel/plugins/auditer.rb', line 59 def audit_owner m = Kernel.const_get(associated_type) m.send(m.auditer_resource_owner_field) || send(m.auditer_resource_owner_field) end |
#audit_user ⇒ Object
Obtains the ‘current_user` based upon the `:auditer_current_user_method’ value set in the audited model, either via defaults or via :user_method config options
# NOTE! this allows overriding the default value on a per audited model
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sequel/plugins/auditer.rb', line 39 def audit_user user = ::Sequel::Auditer::Railtie.user m = Kernel.const_get(associated_type) u = m.send(m.auditer_current_user_method) || send(m.auditer_current_user_method) return u unless u.nil? return user if u.nil? && !user.nil? nil rescue StandardError nil end |
#before_validation ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sequel/plugins/auditer.rb', line 14 def before_validation # grab the current user if u = audit_user self.modifier = u end # grab any additional info if any if i = audit_additional_info self.additional_info = i end # grab resource owner if o = audit_owner self.resource_owner = o end super end |