Skip to content

Commit

Permalink
Use Trello::Utils#from_json for search result
Browse files Browse the repository at this point in the history
  • Loading branch information
rossta committed Nov 26, 2015
1 parent dc0e8e0 commit b09d79b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/trello/action.rb
Expand Up @@ -26,8 +26,9 @@ def find(id, params = {})

def search(query, opts={})
response = client.get("/search/", { query: query }.merge(opts))
JSON.parse(response).except("options").inject({}) do |res, key|
res.merge({ key.first => key.last.jsoned_into("Trello::#{key.first.singularize.capitalize}".constantize) })
JSON.parse(response).except("options").each_with_object({}) do |(key, data), result|
klass = "Trello::#{key.singularize.capitalize}".constantize
result[key] = klass.from_json(data)
end
end
end
Expand Down

0 comments on commit b09d79b

Please sign in to comment.