<commit_before>module HasManyExtended
  DEBUG = false

  # when included enrich the caller with class methods
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods

    # dynamicly create attributes from the join table on this side of the
    # relationship
    #
    def has_many_extended(them, opts={})
      if !opts[:through]
        raise "You must specify a through for has_many_extended"
      end

      # did the user specify what attributes belong to this side of the
      # relationship?
      #
      create_attributes = opts.delete(:attributes)
      
      # first, make sure we have many with the user-given options
      has_many them, opts

      # we are going to use the join class, so lets get one
      join_method = opts[:through]
      join_klass  = opts[:through].to_s.camelize.singularize
      RAILS_DEFAULT_LOGGER.debug("Going to check #{join_klass}") if DEBUG

      # we need an instance of self to figure out the find conditions for
      # the join class
      me       = self.new
      my_class = me.class.name<commit_msg>Inspect the reflections, things might not be what they seem<commit_after>module HasManyExtended
  DEBUG = false

  # when included enrich the caller with class methods
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods

    # dynamicly create attributes from the join table on this side of the
    # relationship
    #
    def has_many_extended(them, opts={})
      if !opts[:through]
        raise "You must specify a through for has_many_extended"
      end

      # did the user specify what attributes belong to this side of the
      # relationship?
      #
      create_attributes = opts.delete(:attributes)
      
      # first, make sure we have many with the user-given options
      has_many them, opts

      # we are going to use the join class, so lets get one
      join_method = opts[:through]

      join_klass = nil

      # find the reflection and check for if there was a class_name set
      if (
        self.reflections.has_key? opts[:through] and
        self.reflections[opts[:through]].options.has_key? :class_name
      ) then
        join_klass = self.reflections[opts[:through]].options[:class_name]

      else
        join_klass  = opts[:through].to_s.camelize.singularize

      end
      
      RAILS_DEFAULT_LOGGER.debug("Going to check #{join_klass}") if DEBUG

      # we need an instance of self to figure out the find conditions for
      # the join class
      me       = self.new
      my_class = me.class.name
{'fraction_non_alphanumeric': 0.064616582327754, 'fraction_numerical': 0.0, 'mean_word_length': 2.609550561797753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '84820', 'n_tokens_mistral': 727, 'n_tokens_neox': 701, 'n_words': 263}