<commit_before>
if Rails::VERSION::STRING >= "3.2"
  module ::ActiveRecord

    class Relation
      attr_accessor :scopes_applied
    end

    module Scoping
      module Named
        module ClassMethods
          attr_accessor :scope_name, :scopes_applied

          def scope_with_applied_names name, scope_options = {}
            name = name.to_sym
            valid_scope_name?(name)
            extension = Module.new(&Proc.new) if block_given?

            scope_proc = lambda do |*args|
              options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options
              options = scoped.apply_finder_options(options) if options.is_a?(Hash)

              relation = scoped.merge(options)
              relation.scopes_applied ||= Set.new
              relation.scopes_applied << name

              extension ? relation.extending(extension) : relation
            end

            singleton_class.send(:redefine_method, name, &scope_proc)
          end<commit_msg>Check if scopes_applied is defined<commit_after>
if Rails::VERSION::STRING >= "3.2"
  module ::ActiveRecord

    class Relation
      attr_accessor :scopes_applied
    end

    module Scoping
      module Named
        module ClassMethods
          attr_accessor :scope_name, :scopes_applied

          def scope_with_applied_names name, scope_options = {}
            name = name.to_sym
            valid_scope_name?(name)
            extension = Module.new(&Proc.new) if block_given?

            scope_proc = lambda do |*args|
              options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options
              options = scoped.apply_finder_options(options) if options.is_a?(Hash)

              relation = scoped.merge(options)
              if relation.respond_to? :scopes_applied
                relation.scopes_applied ||= Set.new
                relation.scopes_applied << name
              end

              extension ? relation.extending(extension) : relation
            end

            singleton_class.send(:redefine_method, name, &scope_proc)
          end
{'fraction_non_alphanumeric': 0.08009367681498829, 'fraction_numerical': 0.001873536299765808, 'mean_word_length': 2.1785714285714284, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6015111', 'n_tokens_mistral': 603, 'n_tokens_neox': 576, 'n_words': 123}