{"action":"closed","issue":{"url":"https://api.github.com/repos/mikeducey/to-do-list_OO/issues/6","repository_url":"https://api.github.com/repos/mikeducey/to-do-list_OO","labels_url":"https://api.github.com/repos/mikeducey/to-do-list_OO/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/mikeducey/to-do-list_OO/issues/6/comments","events_url":"https://api.github.com/repos/mikeducey/to-do-list_OO/issues/6/events","html_url":"https://github.com/mikeducey/to-do-list_OO/issues/6","id":169204712,"number":6,"title":"creating object for method when there are many returns from DB","user":{"login":"mikeducey","id":19538441,"avatar_url":"https://avatars.githubusercontent.com/u/19538441?v=3","gravatar_id":"","url":"https://api.github.com/users/mikeducey","html_url":"https://github.com/mikeducey","followers_url":"https://api.github.com/users/mikeducey/followers","following_url":"https://api.github.com/users/mikeducey/following{/other_user}","gists_url":"https://api.github.com/users/mikeducey/gists{/gist_id}","starred_url":"https://api.github.com/users/mikeducey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikeducey/subscriptions","organizations_url":"https://api.github.com/users/mikeducey/orgs","repos_url":"https://api.github.com/users/mikeducey/repos","events_url":"https://api.github.com/users/mikeducey/events{/privacy}","received_events_url":"https://api.github.com/users/mikeducey/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-03T18:47:37Z","updated_at":"2016-08-04T16:04:54Z","closed_at":"2016-08-04T16:04:54Z","body":"Hi!  Lotta help today... I hope that's okay!\r\n\r\nI'm writing tests for the method that sorts the DB by status.  The method looks as follows: \r\n`\tdef self.sort_by_status(status)\r\n\t\tsorted_tasks = DB.execute(\"SELECT * FROM tasks WHERE status ==#{status}\")\r\n\t\t@status = status\r\n\tend`\r\n\r\nI want to have there be a new object for this method (like seen in the whereID method that makes a new object as follows; \r\n`Task.new(selectedTask[\"id\"], selectedTask[\"task\"], selectedTask[\"name\"], selectedTask[\"status\"])`\r\n\r\nIn this case, I'd obviously change `selectedTask` to `sorted_tasks`.  But the idea is that, after the DB.execute, the variable `sorted_tasks` will contain many rows from the DB (as hashes).  If I want to make an object that I can get values from with the attr_reader, how might I make such an object?\r\n\r\nThought:\r\nWith whereID, I can just call selectedTask[0], but I don't want to call a specific hash from sorted_tasks.  \r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"mikeducey"}}