<commit_before># encoding: utf-8
module Mongoid #:nodoc:
  module Path #:nodoc:
    extend ActiveSupport::Concern
    included do
      cattr_accessor :route
      delegate :route, :to => "self.class"
    end
    module InstanceMethods
      # Return the path to this +Document+ in JSON notation, used for atomic
      # updates via $set in MongoDB.
      #
      # Example:
      #
      # <tt>address.path # returns "addresses"</tt>
      def path
        return route if route
        object, json = self, ""
        while (object._parent) do
          json = "#{object.association_name}#{"." + json unless json.blank?}"
          object = object._parent
        end
        self.route ||= json
      end
    end
  end<commit_msg>Slight path refactoring<commit_after># encoding: utf-8
module Mongoid #:nodoc:
  module Path #:nodoc:
    extend ActiveSupport::Concern
    included do
      cattr_accessor :route
      delegate :route, :to => "self.class"
    end
    module InstanceMethods
      # Return the path to this +Document+ in JSON notation, used for atomic
      # updates via $set in MongoDB.
      #
      # Example:
      #
      # <tt>address.path # returns "addresses"</tt>
      def path
        self.route ||= generate
      end

      protected
      # If the path has not been set, then we need to generate it once.
      def generate
        object, json = self, ""
        while (object._parent) do
          json = "#{object.association_name}#{"." + json unless json.blank?}"
          object = object._parent
        end
        json
      end
    end
  end
{'fraction_non_alphanumeric': 0.09550917141049968, 'fraction_numerical': 0.001265022137887413, 'mean_word_length': 2.0599613152804643, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2838509', 'n_tokens_mistral': 461, 'n_tokens_neox': 455, 'n_words': 152}