From d4010ad76e07c17984a57d2390521e591351b1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapaj=C3=B3s?= Date: Fri, 23 Oct 2009 23:42:48 -0200 Subject: [PATCH] I think that init_method is more semantic that send. --- README.md | 4 ++-- lib/couchrest/more/property.rb | 2 +- spec/fixtures/more/event.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 73e9387..beb6d6c 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,8 @@ you can define some casting rules. property :casted_attribute, :cast_as => 'WithCastedModelMixin' property :keywords, :cast_as => ["String"] - property :occurs_at, :cast_as => 'Time', :send => 'parse - property :end_date, :cast_as => 'Date', :send => 'parse + property :occurs_at, :cast_as => 'Time', :init_method => '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"] diff --git a/lib/couchrest/more/property.rb b/lib/couchrest/more/property.rb index dccc7dd..efede74 100644 --- a/lib/couchrest/more/property.rb +++ b/lib/couchrest/more/property.rb @@ -32,7 +32,7 @@ module CouchRest @alias = options.delete(:alias) if options[:alias] @default = options.delete(:default) unless options[:default].nil? @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 end diff --git a/spec/fixtures/more/event.rb b/spec/fixtures/more/event.rb index 988c5cd..97aa248 100644 --- a/spec/fixtures/more/event.rb +++ b/spec/fixtures/more/event.rb @@ -2,8 +2,8 @@ class Event < CouchRest::ExtendedDocument use_database DB property :subject - property :occurs_at, :cast_as => 'Time', :send => 'parse' - property :end_date, :cast_as => 'Date', :send => 'parse' + property :occurs_at, :cast_as => 'Time', :init_method => 'parse' + property :end_date, :cast_as => 'Date', :init_method => 'parse' end \ No newline at end of file