<commit_before>require 'active_support/concern'

module ActiveRecord
  module Scoping
    module Default
      extend ActiveSupport::Concern

      included do
        # Stores the default scope for the class
        class_attribute :default_scopes, :instance_writer => false
        self.default_scopes = []
      end

      module ClassMethods
        # Returns a scope for this class without taking into account the default_scope.
        #
        #   class Post < ActiveRecord::Base
        #     def self.default_scope
        #       where :published => true
        #     end
        #   end
        #
        #   Post.all          # Fires "SELECT * FROM posts WHERE published = true"
        #   Post.unscoped.all # Fires "SELECT * FROM posts"
        #
        # This method also accepts a block meaning that all queries inside the block will
        # not use the default_scope:
        #
        #   Post.unscoped {
        #     Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
        #   }
        #
        # It is recommended to use block form of unscoped because chaining unscoped with <tt>scope</tt>
        # does not work. Assuming that <tt>published</tt> is a <tt>scope</tt> following two statements are same.
        #
        # Post.unscoped.published
        # Post.published
        def unscoped #:nodoc:
          block_given? ? relation.scoping { yield } : relation
        end

        def before_remove_const #:nodoc:
          self.current_scope = nil
        end

        protected

        # Use this macro in your model to set a default scope for all operations on<commit_msg>Improve doc for ActiveRecord::Base.unscoped.<commit_after>require 'active_support/concern'

module ActiveRecord
  module Scoping
    module Default
      extend ActiveSupport::Concern

      included do
        # Stores the default scope for the class
        class_attribute :default_scopes, :instance_writer => false
        self.default_scopes = []
      end

      module ClassMethods
        # Returns a scope for the model without the default_scope.
        #
        #   class Post < ActiveRecord::Base
        #     def self.default_scope
        #       where :published => true
        #     end
        #   end
        #
        #   Post.all          # Fires "SELECT * FROM posts WHERE published = true"
        #   Post.unscoped.all # Fires "SELECT * FROM posts"
        #
        # This method also accepts a block. All queries inside the block will
        # not use the default_scope:
        #
        #   Post.unscoped {
        #     Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
        #   }
        #
        # It is recommended to use the block form of unscoped because chaining
        # unscoped with <tt>scope</tt> does not work.  Assuming that
        # <tt>published</tt> is a <tt>scope</tt>, the following two statements
        # are equal: the default_scope is applied on both.
        #
        #   Post.unscoped.published
        #   Post.published
        def unscoped #:nodoc:
          block_given? ? relation.scoping { yield } : relation
        end

        def before_remove_const #:nodoc:
          self.current_scope = nil
        end

        protected

        # Use this macro in your model to set a default scope for all operations on
{'fraction_non_alphanumeric': 0.0675552862768858, 'fraction_numerical': 0.0024235080278703423, 'mean_word_length': 1.8588744588744588, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '7480420', 'n_tokens_mistral': 891, 'n_tokens_neox': 867, 'n_words': 301}