aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-04-26 02:03:40 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-04-26 02:03:40 +0000
commit46b58d80b95232bff0435d9e5ab0a3281872005f (patch)
treed830a55006d19ddbef80922e4a253a181c4dd0ff /activeresource/lib/active_resource/base.rb
parent9b8399fb7f97c0b7f7f80ffc8bc2e74565fec642 (diff)
downloadrails-46b58d80b95232bff0435d9e5ab0a3281872005f.tar.gz
rails-46b58d80b95232bff0435d9e5ab0a3281872005f.tar.bz2
rails-46b58d80b95232bff0435d9e5ab0a3281872005f.zip
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
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r--activeresource/lib/active_resource/base.rb7
1 files changed, 5 insertions, 2 deletions
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