Permalink
Browse files

Refactoring:Got rid of get_item_from_id method completely

  • Loading branch information...
1 parent 3e8e14f commit 4277290f860ca527da67270b28b50155c0cd821c Makoto Inoue committed Nov 10, 2008
Showing with 3 additions and 16 deletions.
  1. +3 −16 lib/tc_adapter.rb
View
@@ -189,30 +189,17 @@ def get_id(query)
end
end
- def get_item_from_id(query, value)
- result = get_items_from_id(query, value)
- # access_data(query.model) do |item|
- # raw_data = item.get(value)
- # if raw_data
- # Marshal.load(raw_data)
- # end
- # end
- # p "get_items_from_id: #{result.inspect}"
- end
-
- # TODO: Refactor to consolidate with get_items_from_id method
def get_items_from_id(query, values)
-
- result = values.to_a.map do |value|
+ values_in_array = (values.class == Array ? values : [values])
+ result = values_in_array.map do |value|
access_data(query.model) do |item|
raw_data = item.get(value)
if raw_data
Marshal.load(raw_data)
end
end
end
- result = result.first unless values.class == Array
- result
+ values.class == Array ? result : result.first
end
end # class AbstractAdapter

0 comments on commit 4277290

Please sign in to comment.