{"comment":{"url":"https://api.github.com/repos/shauncarlson/VehicleChooser/comments/19672889","html_url":"https://github.com/shauncarlson/VehicleChooser/commit/9724e6410f39102746c2f05824ae8de1f9fb9077#commitcomment-19672889","id":19672889,"user":{"login":"kevintyll","id":55633,"avatar_url":"https://avatars.githubusercontent.com/u/55633?v=3","gravatar_id":"","url":"https://api.github.com/users/kevintyll","html_url":"https://github.com/kevintyll","followers_url":"https://api.github.com/users/kevintyll/followers","following_url":"https://api.github.com/users/kevintyll/following{/other_user}","gists_url":"https://api.github.com/users/kevintyll/gists{/gist_id}","starred_url":"https://api.github.com/users/kevintyll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevintyll/subscriptions","organizations_url":"https://api.github.com/users/kevintyll/orgs","repos_url":"https://api.github.com/users/kevintyll/repos","events_url":"https://api.github.com/users/kevintyll/events{/privacy}","received_events_url":"https://api.github.com/users/kevintyll/received_events","type":"User","site_admin":false},"position":2,"line":2,"path":"Vehicle.rb","commit_id":"9724e6410f39102746c2f05824ae8de1f9fb9077","created_at":"2016-11-03T02:03:59Z","updated_at":"2016-11-03T02:03:59Z","body":"It's generally good form to define an accessor that gets initialized in the `initialize` method.\r\n`attr_accessor` give public read and write access `attr_reader` gives only public read access.  In this case it looks like an `attr_reader` would suffice.\r\n\r\n`attr_reader :attributes`\r\n\r\nThat will define an `attributes` method to read from, but you have to make the assignment to the instance variable `@attributes`\r\n\r\nso `def get_attribute(attr_name)` would become\r\n```\r\ndef get_attribute(attr_name)\r\n   return attributes[attr_name].nil? ? ''  : attributes[attr_name]\r\n end\r\n```\r\n\r\nThat said, for attributes, it's not too common to create get and set methods like this.  It is generally simplified to just have \r\n```\r\nattr_accessor :attributes\r\n\r\ndef inititialize\r\n  @attributes = Hash.new # it's not good form to have the parens when empty in ruby.\r\nend\r\n```\r\n\r\nThat gives you access to the attributes directly, so you can just make the assignments and read from it directly.\r\n\r\n`Vehicle.attributes[:some_attr] = 'value'`\r\n`Vehicle.attributes[:some_attr]`"}}
{"actor":{"display_login":"kevintyll"}}