Rails 3.2.8の話。ActiveRecordは長いのでARと略す。 findやfirstの実装自体はAR::FinderMethodsで定義されていて、それをincludeすることでAR::Relationのインスタンス(user.postsとかUser.scopedの返り値)から使えるようになっている。 module AR::FinderMethods def first(*args) : end end class ActiveRecord::Relation include FinderMethods end AR::Baseでは、まずAR::Queryingをextendし、この中でAR::Relationのインスタンスに対してfindメソッド等をdeleagateすることで使えるようにしている。 class AR::Base extend Querying end cla