module Pupper::Auditable
Public Instance Methods
audit(*methods)
click to toggle source
# File lib/pupper/auditable.rb, line 6 def audit(*methods) underlying_methods = '' methods.each do |meth| underlying_methods << <<-RB.strip_heredoc def #{meth} audit { super } changes_applied end RB end prepend Module.new { module_eval(underlying_methods, __FILE__, __LINE__) } end
audit_logs()
click to toggle source
# File lib/pupper/auditable.rb, line 33 def audit_logs audit_model.where(auditable_type: model_name.name, auditable_id: primary_key) end
audit_model()
click to toggle source
# File lib/pupper/auditable.rb, line 59 def audit_model @audit_model ||= Pupper.config.audit_with.to_s.classify.constantize end
create_audit_log()
click to toggle source
# File lib/pupper/auditable.rb, line 37 def create_audit_log return unless changed? audit_model.create( auditable_type: model_name.name, auditable_id: primary_key, user: Pupper.config.current_user, what_changed: changes ) end
update_attributes(attrs)
click to toggle source
# File lib/pupper/auditable.rb, line 48 def update_attributes(attrs) run_callbacks(:update) do assign_attributes(attrs) backend.update end changes_applied end