I think that init_method is more semantic that send.

This commit is contained in:
Tapajós 2009-10-23 23:42:48 -02:00
parent 164ef6bc9d
commit d4010ad76e
3 changed files with 5 additions and 5 deletions

View file

@ -149,8 +149,8 @@ you can define some casting rules.
property :casted_attribute, :cast_as => 'WithCastedModelMixin' property :casted_attribute, :cast_as => 'WithCastedModelMixin'
property :keywords, :cast_as => ["String"] property :keywords, :cast_as => ["String"]
property :occurs_at, :cast_as => 'Time', :send => 'parse property :occurs_at, :cast_as => 'Time', :init_method => 'parse
property :end_date, :cast_as => 'Date', :send => 'parse property :end_date, :cast_as => 'Date', :init_method => 'parse
If you want to cast an array of instances from a specific Class, use the trick shown above ["ClassName"] If you want to cast an array of instances from a specific Class, use the trick shown above ["ClassName"]

View file

@ -32,7 +32,7 @@ module CouchRest
@alias = options.delete(:alias) if options[:alias] @alias = options.delete(:alias) if options[:alias]
@default = options.delete(:default) unless options[:default].nil? @default = options.delete(:default) unless options[:default].nil?
@casted = options[:casted] ? true : false @casted = options[:casted] ? true : false
@init_method = options[:send] ? options.delete(:send) : 'new' @init_method = options[:init_method] ? options.delete(:init_method) : 'new'
@options = options @options = options
end end

View file

@ -2,8 +2,8 @@ class Event < CouchRest::ExtendedDocument
use_database DB use_database DB
property :subject property :subject
property :occurs_at, :cast_as => 'Time', :send => 'parse' property :occurs_at, :cast_as => 'Time', :init_method => 'parse'
property :end_date, :cast_as => 'Date', :send => 'parse' property :end_date, :cast_as => 'Date', :init_method => 'parse'
end end