title: How is ruby on rails has_many (and similar) implemented?
body: <p>I am analysing the rails source code, because I wold like to understand the inner workings of the <code>has_many</code> and similar constructs.</p>
  
  <p>So far, I was able to find where the method is implemented (<a href="https://github.com/rails/rails/blob/109db5a55035781166f295d38a2702ce3cc83858/activerecord/lib/active_record/associations.rb" rel="nofollow">link to github</a>): it is in the module ActiveRecord::Associations</p>
  
  <pre><code>def has_many(name, options = {}, &amp;extension)
    Builder::HasMany.build(self, name, options, &amp;extension)
  end
  </code></pre>
  
  <p>This one eventualy ends (<a href="https://github.com/rails/rails/blob/109db5a55035781166f295d38a2702ce3cc83858/activerecord/lib/active_record/associations/builder/collection_association.rb" rel="nofollow">link to github</a>) in the class ActiveRecord::Associations::Builder::CollectionAssociation as</p>
  
  <pre><code>def self.build(model, name, options, &amp;extension)
    new(model, name, options, &amp;extension).build
  end
  </code></pre>
  
  <p>There is where my ruby skills end and I could not track it further and find where is "new" implemented and what it does.</p>
  
  <p>Can someone point me to the right direction and maybe comment along, what is going on under the hood?</p>