<commit_before># encoding: utf-8
module Mongoid #:nodoc:
  module Attributes
    extend ActiveSupport::Concern

    # Get the id associated with this object. This will pull the _id value out
    # of the attributes +Hash+.
    def id
      @attributes["_id"]
    end

    # Set the id of the +Document+ to a new one.
    def id=(new_id)
      @attributes["_id"] = new_id
    end

    alias :_id :id
    alias :_id= :id=

    # Used for allowing accessor methods for dynamic attributes.
    def method_missing(name, *args)
      attr = name.to_s
      return super unless @attributes.has_key?(attr.reader)
      if attr.writer?
        # "args.size > 1" allows to simulate 1.8 behavior of "*args"
        write_attribute(attr.reader, (args.size > 1) ? args : args.first)
      else
        read_attribute(attr.reader)
      end
    end

    # Override respond_to? so it responds properly for dynamic attributes
    def respond_to?(sym)
      (Mongoid.allow_dynamic_fields && @attributes && @attributes.has_key?(sym.to_s)) || super
    end

    # Process the provided attributes casting them to their proper values if a
    # field exists for them on the +Document+. This will be limited to only the
    # attributes provided in the suppied +Hash+ so that no extra nil values get
    # put into the document's attributes.
    def process(attrs = nil)
      sanitize_for_mass_assignment(attrs || {}).each_pair do |key, value|
        if set_allowed?(key)
          write_attribute(key, value)
        else
          if associations.include?(key.to_s) and associations[key.to_s].embedded? and value.is_a?(Hash)
            if association = send(key)
              association.nested_build(value)
            else
              send("build_#{key}", value)
            end
          else
            send("#{key}=", value)<commit_msg>Fix respond_to? override to be friendly with IRB<commit_after># encoding: utf-8
module Mongoid #:nodoc:
  module Attributes
    extend ActiveSupport::Concern

    # Get the id associated with this object. This will pull the _id value out
    # of the attributes +Hash+.
    def id
      @attributes["_id"]
    end

    # Set the id of the +Document+ to a new one.
    def id=(new_id)
      @attributes["_id"] = new_id
    end

    alias :_id :id
    alias :_id= :id=

    # Used for allowing accessor methods for dynamic attributes.
    def method_missing(name, *args)
      attr = name.to_s
      return super unless @attributes.has_key?(attr.reader)
      if attr.writer?
        # "args.size > 1" allows to simulate 1.8 behavior of "*args"
        write_attribute(attr.reader, (args.size > 1) ? args : args.first)
      else
        read_attribute(attr.reader)
      end
    end

    # Override respond_to? so it responds properly for dynamic attributes
    def respond_to?(*args)
      (Mongoid.allow_dynamic_fields && @attributes && @attributes.has_key?(args.first.to_s)) || super
    end

    # Process the provided attributes casting them to their proper values if a
    # field exists for them on the +Document+. This will be limited to only the
    # attributes provided in the suppied +Hash+ so that no extra nil values get
    # put into the document's attributes.
    def process(attrs = nil)
      sanitize_for_mass_assignment(attrs || {}).each_pair do |key, value|
        if set_allowed?(key)
          write_attribute(key, value)
        else
          if associations.include?(key.to_s) and associations[key.to_s].embedded? and value.is_a?(Hash)
            if association = send(key)
              association.nested_build(value)
            else
              send("build_#{key}", value)
            end
          else
            send("#{key}=", value)
{'fraction_non_alphanumeric': 0.09162162162162162, 'fraction_numerical': 0.002702702702702703, 'mean_word_length': 2.5281220209723547, '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': '6580378', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1068, 'n_words': 366}