Repository: rails/rails
File: activerecord/lib/active_record/core.rb (Ruby)

Code before:
      ##
      # :singleton-method:
      # Force enumeration of all columns in SELECT statements.
      # e.g. <tt>SELECT first_name, last_name FROM ...</tt> instead of <tt>SELECT * FROM ...</tt>
      # This avoids +PreparedStatementCacheExpired+ errors when a column is added
      # to the database while the app is running.
      class_attribute :enumerate_columns_in_select_statements, instance_accessor: false, default: false

      class_attribute :belongs_to_required_by_default, instance_accessor: false

      class_attribute :strict_loading_by_default, instance_accessor: false, default: false
      class_attribute :strict_loading_mode, instance_accessor: false, default: :all

      class_attribute :has_many_inversing, instance_accessor: false, default: false

      class_attribute :run_commit_callbacks_on_first_saved_instances_in_transaction, instance_accessor: false, default: true

      class_attribute :default_connection_handler, instance_writer: false

      class_attribute :default_role, instance_writer: false

      class_attribute :default_shard, instance_writer: false

      class_attribute :shard_selector, instance_accessor: false, default: nil

      class_attribute :message_verifiers, instance_accessor: false, instance_predicate: false, default: nil

      ##
      # :singleton-method:
      #
      # Specifies the attributes that will be included in the output of the
      # #inspect method:
      #
      #   Post.attributes_for_inspect = [:id, :title]
      #   Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
      #
      # When set to +:all+ inspect will list all the record's attributes:
      #
      #   Post.attributes_for_inspect = :all
      #   Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
      class_attribute :attributes_for_inspect, instance_accessor: false, default: :all

      def self.application_record_class? # :nodoc:
        if ActiveRecord.application_record_class
          self == ActiveRecord.application_record_class
        else
          if defined?(ApplicationRecord) && self == ApplicationRecord
            true
          end
        end
      end

Review comment (suggestion):
`class_attribute` means that each model class can potentially have its own instance of `message_verifiers`.  We want a single global `message_verifiers` instance, so this should be `singleton_class.attr_accessor`.

That said, maybe this should actually be `ActiveRecord.message_verifiers` instead of `ActiveRecord::Base.message_verifiers`.  That would be more amenable to a pattern of `RAILS_FRAMEWORK.message_verifiers` (e.g. `ActiveSupport.message_verifiers`).

Code after:
      ##
      # :singleton-method:
      # Force enumeration of all columns in SELECT statements.
      # e.g. <tt>SELECT first_name, last_name FROM ...</tt> instead of <tt>SELECT * FROM ...</tt>
      # This avoids +PreparedStatementCacheExpired+ errors when a column is added
      # to the database while the app is running.
      class_attribute :enumerate_columns_in_select_statements, instance_accessor: false, default: false

      class_attribute :belongs_to_required_by_default, instance_accessor: false

      class_attribute :strict_loading_by_default, instance_accessor: false, default: false
      class_attribute :strict_loading_mode, instance_accessor: false, default: :all

      class_attribute :has_many_inversing, instance_accessor: false, default: false

      class_attribute :run_commit_callbacks_on_first_saved_instances_in_transaction, instance_accessor: false, default: true

      class_attribute :default_connection_handler, instance_writer: false

      class_attribute :default_role, instance_writer: false

      class_attribute :default_shard, instance_writer: false

      class_attribute :shard_selector, instance_accessor: false, default: nil

      ##
      # :singleton-method:
      #
      # Specifies the attributes that will be included in the output of the
      # #inspect method:
      #
      #   Post.attributes_for_inspect = [:id, :title]
      #   Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!">"
      #
      # When set to +:all+ inspect will list all the record's attributes:
      #
      #   Post.attributes_for_inspect = :all
      #   Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
      class_attribute :attributes_for_inspect, instance_accessor: false, default: :all

      def self.application_record_class? # :nodoc:
        if ActiveRecord.application_record_class
          self == ActiveRecord.application_record_class
        else
          if defined?(ApplicationRecord) && self == ApplicationRecord
            true
          end
        end
      end

      self.filter_attributes = []