I think that init_method is more semantic that send.
This commit is contained in:
parent
164ef6bc9d
commit
d4010ad76e
|
@ -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"]
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
4
spec/fixtures/more/event.rb
vendored
4
spec/fixtures/more/event.rb
vendored
|
@ -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
|
Loading…
Reference in a new issue