{"action":"created","comment":{"url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/comments/80655386","pull_request_review_id":1697363,"id":80655386,"diff_hunk":"@@ -1,58 +1,55 @@\n module ClassKit\n-  def attr_accessor_type(name, type: nil, collection_type: nil, allow_nil: true, default: nil, auto_init: false, meta: {})\n+  def attr_accessor_type(name, type: nil, collection_type: nil, allow_nil: true, default: nil, auto_init: false,\n+                         meta: {})\n \n-    if !self.class_variable_defined?(:@@class_kit_attributes)\n-      self.class_variable_set(:@@class_kit_attributes, [])\n+    unless class_variable_defined?(:@@class_kit_attributes)\n+      class_variable_set(:@@class_kit_attributes, [])\n     end\n \n-    if !self.class_variable_defined?(:@@is_class_kit_class)\n-      self.class_variable_set(:@@is_class_kit_class, true)\n-    end\n+    attributes = class_variable_get(:@@class_kit_attributes)\n \n-    attributes = self.class_variable_get(:@@class_kit_attributes)\n-    attributes.push({ name: name, type: type, collection_type: collection_type, allow_nil: allow_nil, default: default, auto_init: auto_init, meta: meta })\n-    self.class_variable_set(:@@class_kit_attributes, attributes)\n+    attributes.push({ name: name, type: type, collection_type: collection_type, allow_nil: allow_nil,\n+                                  default: default, auto_init: auto_init, meta: meta })\n \n-    self.class_eval do\n+    class_eval do\n       define_method name do\n-\n         cka = self.class.class_variable_get(:@@class_kit_attributes).detect { |i| i[:name] == name }","path":"lib/class_kit/class_methods.rb","position":27,"original_position":27,"commit_id":"dd689072f8c22a09a6a82f1601c83abe07310917","original_commit_id":"dd689072f8c22a09a6a82f1601c83abe07310917","user":{"login":"vaughanbrittonsage","id":16590464,"avatar_url":"https://avatars.githubusercontent.com/u/16590464?v=3","gravatar_id":"","url":"https://api.github.com/users/vaughanbrittonsage","html_url":"https://github.com/vaughanbrittonsage","followers_url":"https://api.github.com/users/vaughanbrittonsage/followers","following_url":"https://api.github.com/users/vaughanbrittonsage/following{/other_user}","gists_url":"https://api.github.com/users/vaughanbrittonsage/gists{/gist_id}","starred_url":"https://api.github.com/users/vaughanbrittonsage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaughanbrittonsage/subscriptions","organizations_url":"https://api.github.com/users/vaughanbrittonsage/orgs","repos_url":"https://api.github.com/users/vaughanbrittonsage/repos","events_url":"https://api.github.com/users/vaughanbrittonsage/events{/privacy}","received_events_url":"https://api.github.com/users/vaughanbrittonsage/received_events","type":"User","site_admin":false},"body":"Using a Hash is a good idea and something I had considered, however if we did use a Hash we would need to potentially use 2 Hashes to store the data as the attribute helper currently allows attributes to be searched by `[:name]` and also by `[:type]` which means we need to find by more than 1 key. That said the find by `[:type]` is an edge case helper method and the majority of the code and use cases use the find by `[:name]` approach so maybe a compromise would be to keep the array but also maintain a Hash which uses the `[:name]` as the key for performance reasons that can be used for the majority of scenarios. I guess it comes down to what is worse the performance hit of using `.detect` on a small array (I would assume a class should not have more than 10-20 attributes at most if the single responsibility pattern is followed except in extreme cases) or duplicating the list of attributes into Hashes treated like indexes to allow retrieval by a specific key quickly (which would increase the memory footprint slightly and increase complexity).","created_at":"2016-09-27T09:43:42Z","updated_at":"2016-09-27T09:43:43Z","html_url":"https://github.com/vaughanbrittonsage/class_kit/pull/1#discussion_r80655386","pull_request_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/comments/80655386"},"html":{"href":"https://github.com/vaughanbrittonsage/class_kit/pull/1#discussion_r80655386"},"pull_request":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1","id":86881292,"html_url":"https://github.com/vaughanbrittonsage/class_kit/pull/1","diff_url":"https://github.com/vaughanbrittonsage/class_kit/pull/1.diff","patch_url":"https://github.com/vaughanbrittonsage/class_kit/pull/1.patch","issue_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues/1","number":1,"state":"open","locked":false,"title":"Refactor code to obey Ruby coding conventions a bit more","user":{"login":"tosch","id":40520,"avatar_url":"https://avatars.githubusercontent.com/u/40520?v=3","gravatar_id":"","url":"https://api.github.com/users/tosch","html_url":"https://github.com/tosch","followers_url":"https://api.github.com/users/tosch/followers","following_url":"https://api.github.com/users/tosch/following{/other_user}","gists_url":"https://api.github.com/users/tosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tosch/subscriptions","organizations_url":"https://api.github.com/users/tosch/orgs","repos_url":"https://api.github.com/users/tosch/repos","events_url":"https://api.github.com/users/tosch/events{/privacy}","received_events_url":"https://api.github.com/users/tosch/received_events","type":"User","site_admin":false},"body":"This breaks the current API, some methods now take arguments instead of\r\noptions.","created_at":"2016-09-27T08:15:40Z","updated_at":"2016-09-27T09:43:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e77b24cddfcdeea6bc92dca7757ab4b61519c74","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1/commits","review_comments_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1/comments","review_comment_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues/1/comments","statuses_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/statuses/dd689072f8c22a09a6a82f1601c83abe07310917","head":{"label":"tosch:refactoring","ref":"refactoring","sha":"dd689072f8c22a09a6a82f1601c83abe07310917","user":{"login":"tosch","id":40520,"avatar_url":"https://avatars.githubusercontent.com/u/40520?v=3","gravatar_id":"","url":"https://api.github.com/users/tosch","html_url":"https://github.com/tosch","followers_url":"https://api.github.com/users/tosch/followers","following_url":"https://api.github.com/users/tosch/following{/other_user}","gists_url":"https://api.github.com/users/tosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tosch/subscriptions","organizations_url":"https://api.github.com/users/tosch/orgs","repos_url":"https://api.github.com/users/tosch/repos","events_url":"https://api.github.com/users/tosch/events{/privacy}","received_events_url":"https://api.github.com/users/tosch/received_events","type":"User","site_admin":false},"repo":{"id":69326750,"name":"class_kit","full_name":"tosch/class_kit","owner":{"login":"tosch","id":40520,"avatar_url":"https://avatars.githubusercontent.com/u/40520?v=3","gravatar_id":"","url":"https://api.github.com/users/tosch","html_url":"https://github.com/tosch","followers_url":"https://api.github.com/users/tosch/followers","following_url":"https://api.github.com/users/tosch/following{/other_user}","gists_url":"https://api.github.com/users/tosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tosch/subscriptions","organizations_url":"https://api.github.com/users/tosch/orgs","repos_url":"https://api.github.com/users/tosch/repos","events_url":"https://api.github.com/users/tosch/events{/privacy}","received_events_url":"https://api.github.com/users/tosch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tosch/class_kit","description":null,"fork":true,"url":"https://api.github.com/repos/tosch/class_kit","forks_url":"https://api.github.com/repos/tosch/class_kit/forks","keys_url":"https://api.github.com/repos/tosch/class_kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tosch/class_kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tosch/class_kit/teams","hooks_url":"https://api.github.com/repos/tosch/class_kit/hooks","issue_events_url":"https://api.github.com/repos/tosch/class_kit/issues/events{/number}","events_url":"https://api.github.com/repos/tosch/class_kit/events","assignees_url":"https://api.github.com/repos/tosch/class_kit/assignees{/user}","branches_url":"https://api.github.com/repos/tosch/class_kit/branches{/branch}","tags_url":"https://api.github.com/repos/tosch/class_kit/tags","blobs_url":"https://api.github.com/repos/tosch/class_kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tosch/class_kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tosch/class_kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/tosch/class_kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tosch/class_kit/statuses/{sha}","languages_url":"https://api.github.com/repos/tosch/class_kit/languages","stargazers_url":"https://api.github.com/repos/tosch/class_kit/stargazers","contributors_url":"https://api.github.com/repos/tosch/class_kit/contributors","subscribers_url":"https://api.github.com/repos/tosch/class_kit/subscribers","subscription_url":"https://api.github.com/repos/tosch/class_kit/subscription","commits_url":"https://api.github.com/repos/tosch/class_kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/tosch/class_kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/tosch/class_kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/tosch/class_kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/tosch/class_kit/contents/{+path}","compare_url":"https://api.github.com/repos/tosch/class_kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tosch/class_kit/merges","archive_url":"https://api.github.com/repos/tosch/class_kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tosch/class_kit/downloads","issues_url":"https://api.github.com/repos/tosch/class_kit/issues{/number}","pulls_url":"https://api.github.com/repos/tosch/class_kit/pulls{/number}","milestones_url":"https://api.github.com/repos/tosch/class_kit/milestones{/number}","notifications_url":"https://api.github.com/repos/tosch/class_kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tosch/class_kit/labels{/name}","releases_url":"https://api.github.com/repos/tosch/class_kit/releases{/id}","deployments_url":"https://api.github.com/repos/tosch/class_kit/deployments","created_at":"2016-09-27T06:34:57Z","updated_at":"2016-09-27T06:34:58Z","pushed_at":"2016-09-27T08:48:59Z","git_url":"git://github.com/tosch/class_kit.git","ssh_url":"git@github.com:tosch/class_kit.git","clone_url":"https://github.com/tosch/class_kit.git","svn_url":"https://github.com/tosch/class_kit","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vaughanbrittonsage:master","ref":"master","sha":"52791158b4038ab7df08ea9b4b5c7e30a7fa3379","user":{"login":"vaughanbrittonsage","id":16590464,"avatar_url":"https://avatars.githubusercontent.com/u/16590464?v=3","gravatar_id":"","url":"https://api.github.com/users/vaughanbrittonsage","html_url":"https://github.com/vaughanbrittonsage","followers_url":"https://api.github.com/users/vaughanbrittonsage/followers","following_url":"https://api.github.com/users/vaughanbrittonsage/following{/other_user}","gists_url":"https://api.github.com/users/vaughanbrittonsage/gists{/gist_id}","starred_url":"https://api.github.com/users/vaughanbrittonsage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaughanbrittonsage/subscriptions","organizations_url":"https://api.github.com/users/vaughanbrittonsage/orgs","repos_url":"https://api.github.com/users/vaughanbrittonsage/repos","events_url":"https://api.github.com/users/vaughanbrittonsage/events{/privacy}","received_events_url":"https://api.github.com/users/vaughanbrittonsage/received_events","type":"User","site_admin":false},"repo":{"id":65566838,"name":"class_kit","full_name":"vaughanbrittonsage/class_kit","owner":{"login":"vaughanbrittonsage","id":16590464,"avatar_url":"https://avatars.githubusercontent.com/u/16590464?v=3","gravatar_id":"","url":"https://api.github.com/users/vaughanbrittonsage","html_url":"https://github.com/vaughanbrittonsage","followers_url":"https://api.github.com/users/vaughanbrittonsage/followers","following_url":"https://api.github.com/users/vaughanbrittonsage/following{/other_user}","gists_url":"https://api.github.com/users/vaughanbrittonsage/gists{/gist_id}","starred_url":"https://api.github.com/users/vaughanbrittonsage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaughanbrittonsage/subscriptions","organizations_url":"https://api.github.com/users/vaughanbrittonsage/orgs","repos_url":"https://api.github.com/users/vaughanbrittonsage/repos","events_url":"https://api.github.com/users/vaughanbrittonsage/events{/privacy}","received_events_url":"https://api.github.com/users/vaughanbrittonsage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vaughanbrittonsage/class_kit","description":null,"fork":false,"url":"https://api.github.com/repos/vaughanbrittonsage/class_kit","forks_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/forks","keys_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/teams","hooks_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/hooks","issue_events_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues/events{/number}","events_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/events","assignees_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/assignees{/user}","branches_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/branches{/branch}","tags_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/tags","blobs_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/statuses/{sha}","languages_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/languages","stargazers_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/stargazers","contributors_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/contributors","subscribers_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/subscribers","subscription_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/subscription","commits_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/contents/{+path}","compare_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/merges","archive_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/downloads","issues_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues{/number}","pulls_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls{/number}","milestones_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/milestones{/number}","notifications_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/labels{/name}","releases_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/releases{/id}","deployments_url":"https://api.github.com/repos/vaughanbrittonsage/class_kit/deployments","created_at":"2016-08-12T16:20:01Z","updated_at":"2016-08-12T16:20:54Z","pushed_at":"2016-09-27T08:48:59Z","git_url":"git://github.com/vaughanbrittonsage/class_kit.git","ssh_url":"git@github.com:vaughanbrittonsage/class_kit.git","clone_url":"https://github.com/vaughanbrittonsage/class_kit.git","svn_url":"https://github.com/vaughanbrittonsage/class_kit","homepage":null,"size":19,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1"},"html":{"href":"https://github.com/vaughanbrittonsage/class_kit/pull/1"},"issue":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues/1"},"comments":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/vaughanbrittonsage/class_kit/statuses/dd689072f8c22a09a6a82f1601c83abe07310917"}}}}
{"actor":{"display_login":"vaughanbrittonsage"}}