From 46b58d80b95232bff0435d9e5ab0a3281872005f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 26 Apr 2007 02:03:40 +0000 Subject: The find should instantiate real objects, not return hashes git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6585 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activeresource/lib/active_resource/base.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activeresource/lib/active_resource/base.rb') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 6fa301d740..be0560879d 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -122,7 +122,7 @@ module ActiveResource case scope when :all then find_every(options) when :first then find_every(options).first - when Symbol then get(scope, options) + when Symbol then instantiate_collection(get(scope, options)) else find_single(scope, options) end end @@ -142,7 +142,10 @@ module ActiveResource # Find every resource. def find_every(options) prefix_options, query_options = split_options(options) - collection = connection.get(collection_path(prefix_options, query_options)) || [] + instantiate_collection(connection.get(collection_path(prefix_options, query_options)) || []) + end + + def instantiate_collection(collection, prefix_options = {}) collection.collect! do |element| returning new(element) do |resource| resource.prefix_options = prefix_options -- cgit v1.2.3