Sha256: 4e6b99cc0fb6c9d7f08515ab74992a5ab5569372c9d531551a62d06cabe19b5f
Contents?: true
Size: 1.45 KB
Versions: 17
Compression:
Stored size: 1.45 KB
Contents
module BetterRecord class LoggedAction < Base # == Constants ============================================================ ACTIONS = { D: 'DELETE', I: 'INSERT', U: 'UPDATE', T: 'TRUNCATE', }.with_indifferent_access # == Attributes =========================================================== self.table_name = "#{BetterRecord.db_audit_schema}.logged_actions" # == Extensions =========================================================== # == Relationships ======================================================== belongs_to :audited, polymorphic: :true, primary_type: :table_name, foreign_key: :row_id, foreign_type: :table_name # == Validations ========================================================== # == Scopes =============================================================== # == Callbacks ============================================================ # == Class Methods ======================================================== def self.default_print [ :event_id, :row_id, :table_name, :app_user_id, :app_user_type, :action_type, :changed_columns ] end # == Instance Methods ===================================================== def changed_columns (self.changed_fields || {}).keys.join(', ').presence || 'N/A' end def action_type ACTIONS[action] || 'UNKNOWN' end end end
Version data entries
17 entries across 17 versions & 1 rubygems