Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring:Got rid of get_item_from_id method completely

  • Loading branch information...
commit 4277290f860ca527da67270b28b50155c0cd821c 1 parent 3e8e14f
Makoto Inoue authored
Showing with 3 additions and 16 deletions.
  1. +3 −16 lib/tc_adapter.rb
View
19 lib/tc_adapter.rb
@@ -189,21 +189,9 @@ 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
@@ -211,8 +199,7 @@ def get_items_from_id(query, values)
end
end
end
- result = result.first unless values.class == Array
- result
+ values.class == Array ? result : result.first
end
end # class AbstractAdapter
Please sign in to comment.
Something went wrong with that request. Please try again.