I am analysing the rails source code, because I wold like to understand the inner workings of the has_many
and similar constructs.
So far, I was able to find where the method is implemented (link to github): it is in the module ActiveRecord::Associations
def has_many(name, options = {}, &extension)
Builder::HasMany.build(self, name, options, &extension)
end
This one eventualy ends (link to github) in the class ActiveRecord::Associations::Builder::CollectionAssociation as
def self.build(model, name, options, &extension)
new(model, name, options, &extension).build
end
There is where my ruby skills end and I could not track it further and find where is "new" implemented and what it does.
Can someone point me to the right direction and maybe comment along, what is going on under the hood?