Sha256: c28d25aa43ff4d1674049fb7c0396ef4f2167688bd9c57e0a03a8a620b771b86

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require "active_record"

module Audited
  class << self
    attr_accessor \
      :auditing_enabled,
      :current_user_method,
      :ignored_attributes,
      :max_audits,
      :store_synthesized_enums
    attr_writer :audit_class

    def audit_class
      # The audit_class is set as String in the initializer. It can not be constantized during initialization and must
      # be constantized at runtime. See https://github.com/collectiveidea/audited/issues/608
      @audit_class = @audit_class.safe_constantize if @audit_class.is_a?(String)
      @audit_class ||= Audited::Audit
    end

    # remove audit_model in next major version it was only shortly present in 5.1.0
    alias_method :audit_model, :audit_class
    deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed."

    def store
      current_store_value = Thread.current.thread_variable_get(:audited_store)

      if current_store_value.nil?
        Thread.current.thread_variable_set(:audited_store, {})
      else
        current_store_value
      end
    end

    def config
      yield(self)
    end
  end

  @ignored_attributes = %w[lock_version created_at updated_at created_on updated_on]

  @current_user_method = :current_user
  @auditing_enabled = true
  @store_synthesized_enums = false
end

require "audited/auditor"

ActiveSupport.on_load :active_record do
  require "audited/audit"
  include Audited::Auditor
end

require "audited/sweeper"
require "audited/railtie"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
audited-5.3.2 lib/audited.rb
audited-5.3.1 lib/audited.rb
audited-5.3.0 lib/audited.rb
audited-5.2.0 lib/audited.rb