僕はMerbではDataMapperを使うのがお勧めだと思いますが、 DataMapperで利用可能なpropertyの型をまとめておきます。

  • TrueClass, Boolean
  • String
  • Text (デフォルトでは65536バイト)
  • Float
  • Integer
  • BigDecimal
  • DateTime
  • Date
  • Time
  • Object (マーシャル/アンマーシャルされる)
  • Class (Stringと同様に扱われる)

基本的には、

   1  property :name, Type[, options]

という感じで利用します。

optionsとしては、Hashの形式で以下のようなものが指定出来ます。

  • :accessor, :reader, :writer => :private, :protected, :public
  • :nullable => true
  • :default => value
  • :lazy => true, false (遅延読み込みのオン/オフ)
  • :key => true (Model[key]でアクセスできるようになる)
  • :index => true, "name" (インデックスを作成)
  • :size => length (テキストの長さなど)
  • and so on...

See Also

posted by Png genki on Fri 19 Dec 2008 at 15:28

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry1148
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ