Permalink
Browse files

Fix .find after rebase

  • Loading branch information...
1 parent 2753e25 commit 609f9b7d3d200062fd318803a79f9e3dccf3328a @remiprev committed Aug 27, 2012
Showing with 6 additions and 10 deletions.
  1. +6 −10 lib/her/model/orm.rb
View
@@ -151,23 +151,19 @@ def new_collection(parsed_data) # {{{
# # Fetched via GET "/users/1"
#
# @example
- # @users = User.find(1, 2)
+ # @users = User.find([1, 2])
# # Fetched via GET "/users/1" and GET "/users/2"
def find(*ids) # {{{
params = ids.last.is_a?(Hash) ? ids.pop : {}
- results = ids.map do |id|
- request_params = params.merge(
- :_method => :get,
- :_path => "#{build_request_path(params.merge(:id => id))}"
- )
- request(request_params) do |parsed_data|
+ results = ids.flatten.compact.uniq.map do |id|
+ request(params.merge(:_method => :get, :_path => "#{build_request_path(params.merge(:id => id))}")) do |parsed_data|
new(parsed_data[:data])
end
end
- if ids.length == 1 || ids.first.kind_of?(Array)
- results.first
- else
+ if ids.length > 1 || ids.first.kind_of?(Array)
results
+ else
+ results.first
end
end # }}}

0 comments on commit 609f9b7

Please sign in to comment.