Sha256: b61c1da9547d2279c8d37238a567ef66cda269c03245a709e161fbe175ab7624

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'singleton'

module PaperTrail
  class Config
    include Singleton
    attr_accessor :enabled, :timestamp_field, :serializer, :version_limit
    attr_reader :serialized_attributes
    attr_writer :track_associations

    def initialize
      @enabled         = true # Indicates whether PaperTrail is on or off.
      @timestamp_field = :created_at
      @serializer      = PaperTrail::Serializers::YAML

      # This setting only defaults to false on AR 4.2+, because that's when
      # it was deprecated. We want it to function with older versions of
      # ActiveRecord by default.
      if ::ActiveRecord::VERSION::STRING < '4.2'
        @serialized_attributes = true
      end
    end

    def serialized_attributes=(value)
      if ::ActiveRecord::VERSION::MAJOR >= 5
        warn("DEPRECATED: ActiveRecord 5.0 deprecated `serialized_attributes` "  +
          "without replacement, so this PaperTrail config setting does " +
          "nothing with this version, and is always turned off")
      end
      @serialized_attributes = value
    end

    def track_associations
      @track_associations ||= PaperTrail::VersionAssociation.table_exists?
    end
    alias_method :track_associations?, :track_associations
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paper_trail-4.0.0.rc1 lib/paper_trail/config.rb