2009-09-01から1ヶ月間の記事一覧

DataMapper Reading (はじまり)

DataMapper のコードを読む.最終的には Adapter を実装したい. 公式 http://datamapper.org/ github http://github.com/datamapper 作業環境 OS ubuntu 9.04 DataMapper 0.9.11 (data_objects や extlib は 0.9.12) でもこれは途中まで (0.10.1 に上がって…

DataMapper を使う (Hook)

メソッド呼び出し前後に callback を仕掛けることができる. DataMapper Hooks http://datamapper.org/doku.php?id=docs:hooks インスタンスメソッドに対する Hook class Post include DataMapper::Resource ... before :save, :do_before_save # save メソ…

DataMapper を使う (Single Table Inheritance)

DataMapper で STI を表現する場合は,以下のようにする. class Person include DataMapper::Resource property :id, Serial property :name, String property :type, Discriminator ... end class Employee < Person property :dept, String # 所属 end cl…

twitter はじめてみた

とりあえずさわってみよう,ということで. サイドバーに表示させてみた.

DataMapper を使う (Index)

以下の記事によれば,property の定義で index の指定ができるようです. http://jlaine.net/2008/6/2/specifying-indeces-in-datamapper 具体的には,property 定義で :index => true を指定する. unique index にしたい場合は :unique_index => true を指…

DataMapper を使う (Transactions)

今回は Transaction 機能について. 公式サイト http://datamapper.org/doku.php?id=docs:transactions 環境 dm-core-0.9.11 モデル定義 class Account include DataMapper::Resource property :id, Serial property :name, String, :nullable => false prop…

DataMapper を使う (Associations)

目次 has n and belongs_to (One-To-Many) has n, :through (One-To-Many-Through) ここでちょっと補足 has, and belongs to, many (Or Many-To-Many) Self-Referential Has, and belongs to, many Adding To Associations Removing From Associations Custo…