<commit_before>module ActsAsContextual
  module ActsAsContext
    extend ActiveSupport::Concern

    module ClassMethods
      def acts_as_contextual(*options) 
        opts = options.extract_options!
        include ActsAsContext::InstanceMethodsOnlyActsAsContext
        if opts[:allow_contextualisation]
          attr_writer :context_id
          belongs_to :context, :class_name => ActsAsContextual.config.current_context.class.name
        end

        after_save :ensure_is_contextualized    

        has_one :contextualizable, :as => :contextualized
        
        default_scope do 
          unless ActsAsContextual.config.current_context.nil?
            where(["#{Contextualizable.table_name}.contextualizer_id = ? and #{Contextualizable.table_name}.contextualizer_type = ?", ActsAsContextual.config.current_context.id, ActsAsContextual.config.current_context.class.name]).includes(:contextualizable)
          end
        end

      end

    end
<commit_msg>add option defautl_scoped<commit_after>module ActsAsContextual
  module ActsAsContext
    extend ActiveSupport::Concern

    module ClassMethods
      def acts_as_contextual(*options) 
        opts = options.extract_options!
        include ActsAsContext::InstanceMethodsOnlyActsAsContext
        if opts[:allow_contextualisation]
          attr_writer :context_id
          belongs_to :context, :class_name => ActsAsContextual.config.current_context.class.name
        end

        after_save :ensure_is_contextualized    

        has_one :contextualizable, :as => :contextualized
        
        default_scope do 
          unless ActsAsContextual.config.current_context.nil?
            contextualized
          end 
        end if opts[:default_scoped]

        scope :contextualized, lambda { |ctx = ActsAsContextual.config.current_context |
            where(["#{Contextualizable.table_name}.contextualizer_id = ? and #{Contextualizable.table_name}.contextualizer_type = ?", ctx.id, ctx.class.name]).includes(:contextualizable)
        }

      end

    end

{'fraction_non_alphanumeric': 0.07258460029426189, 'fraction_numerical': 0.0, 'mean_word_length': 3.0396039603960396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7049228', 'n_tokens_mistral': 579, 'n_tokens_neox': 551, 'n_words': 94}