<commit_before>require 'singleton'
require 'paper_trail/serializers/yaml'

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

    def initialize
      @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
        ::ActiveSupport::Deprecation.warn(
          "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

    # Indicates whether PaperTrail is on or off.
    def enabled
      PaperTrail.paper_trail_store[:paper_trail_enabled].nil? || PaperTrail.paper_trail_store[:paper_trail_enabled]
    end

    def enabled= enable
      PaperTrail.paper_trail_store[:paper_trail_enabled] = enable
    end
  end
end
<commit_msg>In track_associations, only check db if no config<commit_after>require 'singleton'
require 'paper_trail/serializers/yaml'

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

    def initialize
      @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
        ::ActiveSupport::Deprecation.warn(
          "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.nil? ?
        PaperTrail::VersionAssociation.table_exists? :
        @track_associations
    end
    alias_method :track_associations?, :track_associations

    # Indicates whether PaperTrail is on or off.
    def enabled
      PaperTrail.paper_trail_store[:paper_trail_enabled].nil? || PaperTrail.paper_trail_store[:paper_trail_enabled]
    end

    def enabled= enable
      PaperTrail.paper_trail_store[:paper_trail_enabled] = enable
    end
  end
end

{'fraction_non_alphanumeric': 0.07086614173228346, 'fraction_numerical': 0.004409448818897638, 'mean_word_length': 3.229027962716378, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1748485', 'n_tokens_mistral': 918, 'n_tokens_neox': 885, 'n_words': 242}