Sha256: 15b738ef52f95786705793f866b9f8e308217e78616056cdf08bf4098c66baf3
Contents?: true
Size: 1.64 KB
Versions: 45
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true 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 ============================================================ # == Boolean Class Methods ================================================ # == Class Methods ======================================================== def self.default_print [ :event_id, :row_id, :table_name, :app_user_id, :app_user_type, :action_type, :changed_columns ] end # == Boolean Methods ====================================================== # == 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
45 entries across 45 versions & 1 rubygems