{"action":"created","comment":{"url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/comments/319301739","pull_request_review_id":281760032,"id":319301739,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxOTMwMTczOQ==","diff_hunk":"@@ -114,28 +114,72 @@ def wood_type\n     end\n   RUBY\n \n-  file \"app/models/wizard.rb\", <<~RUBY\n-    class Wizard < ApplicationRecord\n-      validates :name, length: { minimum: 5 }, presence: true\n-\n-      enum house: {\n-        Gryffindor: 0,\n-        Hufflepuff: 1,\n-        Ravenclaw: 2,\n-        Slytherin: 3,\n-      }\n-\n-      enum broom: {\n-        nimbus: 'nimbus',\n-        firebolt: 'firebolt',\n-      }\n-\n-      has_one :wand\n-      has_many :spell_books\n-\n-      scope :recent, -> { where('created_at > ?', 1.month.ago) }\n-    end\n-  RUBY\n+  if ENV[\"RAILS_VERSION\"] == \"4.2\"\n+    file \"app/models/wizard.rb\", <<~RUBY\n+      class Wizard < ApplicationRecord\n+        validates :name, length: { minimum: 5 }, presence: true\n+\n+        enum house: {\n+          Gryffindor: 0,\n+          Hufflepuff: 1,\n+          Ravenclaw: 2,\n+          Slytherin: 3,\n+        }\n+\n+        enum broom: {\n+          nimbus: 'nimbus',\n+          firebolt: 'firebolt',\n+        }\n+\n+        has_one :wand\n+        has_many :spell_books\n+\n+        scope :recent, -> { where('created_at > ?', 1.month.ago) }\n+      end\n+    RUBY\n+  else\n+    file \"app/models/wizard.rb\", <<~RUBY\n+      class Wizard < ApplicationRecord\n+        validates :name, length: { minimum: 5 }, presence: true\n+\n+        enum house: {\n+          Gryffindor: 0,\n+          Hufflepuff: 1,\n+          Ravenclaw: 2,\n+          Slytherin: 3,\n+        }\n+\n+        enum broom: {\n+          nimbus: 'nimbus',\n+          firebolt: 'firebolt',\n+        }, _prefix: true\n+\n+        enum quidditch_position: {\n+          keeper: 0,\n+          seeker: 1,\n+          beater: 2,\n+          chaser: 3,\n+        }, _prefix: :quidditch\n+\n+        enum hair_color: {\n+          brown: 0,\n+          black: 1,\n+          blonde: 2,\n+        }, _suffix: :hair\n+\n+        enum eye_color: {","path":"spec/generators/rails-template.rb","position":74,"original_position":79,"commit_id":"9b131d9029632ae6d2b362fc84720dc38deb164b","original_commit_id":"9b131d9029632ae6d2b362fc84720dc38deb164b","user":{"login":"deecewan","id":4755785,"node_id":"MDQ6VXNlcjQ3NTU3ODU=","avatar_url":"https://avatars0.githubusercontent.com/u/4755785?v=4","gravatar_id":"","url":"https://api.github.com/users/deecewan","html_url":"https://github.com/deecewan","followers_url":"https://api.github.com/users/deecewan/followers","following_url":"https://api.github.com/users/deecewan/following{/other_user}","gists_url":"https://api.github.com/users/deecewan/gists{/gist_id}","starred_url":"https://api.github.com/users/deecewan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deecewan/subscriptions","organizations_url":"https://api.github.com/users/deecewan/orgs","repos_url":"https://api.github.com/users/deecewan/repos","events_url":"https://api.github.com/users/deecewan/events{/privacy}","received_events_url":"https://api.github.com/users/deecewan/received_events","type":"User","site_admin":false},"body":"sure! the point of this one was from some earlier testing, because the old system would have declared 2 `brown?` methods (one for hair, one for eyes) and I was trying to figure out a better way to get the methods. Now, tho, I'll add a prefix/suffix case","created_at":"2019-08-29T22:49:55Z","updated_at":"2019-08-29T22:49:56Z","html_url":"https://github.com/chanzuckerberg/sorbet-rails/pull/145#discussion_r319301739","pull_request_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/comments/319301739"},"html":{"href":"https://github.com/chanzuckerberg/sorbet-rails/pull/145#discussion_r319301739"},"pull_request":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145"}},"in_reply_to_id":319265896},"pull_request":{"url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145","id":312079296,"node_id":"MDExOlB1bGxSZXF1ZXN0MzEyMDc5Mjk2","html_url":"https://github.com/chanzuckerberg/sorbet-rails/pull/145","diff_url":"https://github.com/chanzuckerberg/sorbet-rails/pull/145.diff","patch_url":"https://github.com/chanzuckerberg/sorbet-rails/pull/145.patch","issue_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues/145","number":145,"state":"open","locked":false,"title":"A couple of fixes for enums","user":{"login":"deecewan","id":4755785,"node_id":"MDQ6VXNlcjQ3NTU3ODU=","avatar_url":"https://avatars0.githubusercontent.com/u/4755785?v=4","gravatar_id":"","url":"https://api.github.com/users/deecewan","html_url":"https://github.com/deecewan","followers_url":"https://api.github.com/users/deecewan/followers","following_url":"https://api.github.com/users/deecewan/following{/other_user}","gists_url":"https://api.github.com/users/deecewan/gists{/gist_id}","starred_url":"https://api.github.com/users/deecewan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deecewan/subscriptions","organizations_url":"https://api.github.com/users/deecewan/orgs","repos_url":"https://api.github.com/users/deecewan/repos","events_url":"https://api.github.com/users/deecewan/events{/privacy}","received_events_url":"https://api.github.com/users/deecewan/received_events","type":"User","site_admin":false},"body":"There were a couple of things that didn't work _quite_ right with the enum types.\r\n\r\nThe first was the return type. It's not always an integer. Some places, including my company, use a string instead, to make the process of adding/removing enum values simpler and safer.\r\n\r\nThe second was the lack of support for prefix and suffix options. This would create types for methods that definitely didn't exist, and miss types for methods that definitely did exist.\r\n\r\nUnfortunately, the only way I could think of to fix this was to cache every call to the `enum` method, and then can use it do statically determine if a prefix or suffix needs to be added. I followed the logic [here](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/enum.rb#L177) for determining the name.\r\n\r\nRails 4.2 doesn't support prefix or suffix. I've removed support for it, but unsure if that's allowed/recommended.","created_at":"2019-08-28T23:44:34Z","updated_at":"2019-08-29T22:49:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b225437136a5085673171efccd526ac1d175db72","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145/commits","review_comments_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145/comments","review_comment_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues/145/comments","statuses_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/statuses/9b131d9029632ae6d2b362fc84720dc38deb164b","head":{"label":"deecewan:fix/correct-enum-methods","ref":"fix/correct-enum-methods","sha":"9b131d9029632ae6d2b362fc84720dc38deb164b","user":{"login":"deecewan","id":4755785,"node_id":"MDQ6VXNlcjQ3NTU3ODU=","avatar_url":"https://avatars0.githubusercontent.com/u/4755785?v=4","gravatar_id":"","url":"https://api.github.com/users/deecewan","html_url":"https://github.com/deecewan","followers_url":"https://api.github.com/users/deecewan/followers","following_url":"https://api.github.com/users/deecewan/following{/other_user}","gists_url":"https://api.github.com/users/deecewan/gists{/gist_id}","starred_url":"https://api.github.com/users/deecewan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deecewan/subscriptions","organizations_url":"https://api.github.com/users/deecewan/orgs","repos_url":"https://api.github.com/users/deecewan/repos","events_url":"https://api.github.com/users/deecewan/events{/privacy}","received_events_url":"https://api.github.com/users/deecewan/received_events","type":"User","site_admin":false},"repo":{"id":201177435,"node_id":"MDEwOlJlcG9zaXRvcnkyMDExNzc0MzU=","name":"sorbet-rails","full_name":"deecewan/sorbet-rails","private":false,"owner":{"login":"deecewan","id":4755785,"node_id":"MDQ6VXNlcjQ3NTU3ODU=","avatar_url":"https://avatars0.githubusercontent.com/u/4755785?v=4","gravatar_id":"","url":"https://api.github.com/users/deecewan","html_url":"https://github.com/deecewan","followers_url":"https://api.github.com/users/deecewan/followers","following_url":"https://api.github.com/users/deecewan/following{/other_user}","gists_url":"https://api.github.com/users/deecewan/gists{/gist_id}","starred_url":"https://api.github.com/users/deecewan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deecewan/subscriptions","organizations_url":"https://api.github.com/users/deecewan/orgs","repos_url":"https://api.github.com/users/deecewan/repos","events_url":"https://api.github.com/users/deecewan/events{/privacy}","received_events_url":"https://api.github.com/users/deecewan/received_events","type":"User","site_admin":false},"html_url":"https://github.com/deecewan/sorbet-rails","description":"A set of tools to make the Sorbet typechecker work with Ruby on Rails seamlessly.","fork":true,"url":"https://api.github.com/repos/deecewan/sorbet-rails","forks_url":"https://api.github.com/repos/deecewan/sorbet-rails/forks","keys_url":"https://api.github.com/repos/deecewan/sorbet-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deecewan/sorbet-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deecewan/sorbet-rails/teams","hooks_url":"https://api.github.com/repos/deecewan/sorbet-rails/hooks","issue_events_url":"https://api.github.com/repos/deecewan/sorbet-rails/issues/events{/number}","events_url":"https://api.github.com/repos/deecewan/sorbet-rails/events","assignees_url":"https://api.github.com/repos/deecewan/sorbet-rails/assignees{/user}","branches_url":"https://api.github.com/repos/deecewan/sorbet-rails/branches{/branch}","tags_url":"https://api.github.com/repos/deecewan/sorbet-rails/tags","blobs_url":"https://api.github.com/repos/deecewan/sorbet-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deecewan/sorbet-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deecewan/sorbet-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/deecewan/sorbet-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deecewan/sorbet-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/deecewan/sorbet-rails/languages","stargazers_url":"https://api.github.com/repos/deecewan/sorbet-rails/stargazers","contributors_url":"https://api.github.com/repos/deecewan/sorbet-rails/contributors","subscribers_url":"https://api.github.com/repos/deecewan/sorbet-rails/subscribers","subscription_url":"https://api.github.com/repos/deecewan/sorbet-rails/subscription","commits_url":"https://api.github.com/repos/deecewan/sorbet-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/deecewan/sorbet-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/deecewan/sorbet-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/deecewan/sorbet-rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/deecewan/sorbet-rails/contents/{+path}","compare_url":"https://api.github.com/repos/deecewan/sorbet-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deecewan/sorbet-rails/merges","archive_url":"https://api.github.com/repos/deecewan/sorbet-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deecewan/sorbet-rails/downloads","issues_url":"https://api.github.com/repos/deecewan/sorbet-rails/issues{/number}","pulls_url":"https://api.github.com/repos/deecewan/sorbet-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/deecewan/sorbet-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/deecewan/sorbet-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deecewan/sorbet-rails/labels{/name}","releases_url":"https://api.github.com/repos/deecewan/sorbet-rails/releases{/id}","deployments_url":"https://api.github.com/repos/deecewan/sorbet-rails/deployments","created_at":"2019-08-08T04:21:46Z","updated_at":"2019-08-08T04:21:49Z","pushed_at":"2019-08-29T02:11:03Z","git_url":"git://github.com/deecewan/sorbet-rails.git","ssh_url":"git@github.com:deecewan/sorbet-rails.git","clone_url":"https://github.com/deecewan/sorbet-rails.git","svn_url":"https://github.com/deecewan/sorbet-rails","homepage":"","size":1204,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chanzuckerberg:master","ref":"master","sha":"f95db8d998a964a695a19e1655d99de11cad2d7f","user":{"login":"chanzuckerberg","id":19917299,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTE3Mjk5","avatar_url":"https://avatars2.githubusercontent.com/u/19917299?v=4","gravatar_id":"","url":"https://api.github.com/users/chanzuckerberg","html_url":"https://github.com/chanzuckerberg","followers_url":"https://api.github.com/users/chanzuckerberg/followers","following_url":"https://api.github.com/users/chanzuckerberg/following{/other_user}","gists_url":"https://api.github.com/users/chanzuckerberg/gists{/gist_id}","starred_url":"https://api.github.com/users/chanzuckerberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanzuckerberg/subscriptions","organizations_url":"https://api.github.com/users/chanzuckerberg/orgs","repos_url":"https://api.github.com/users/chanzuckerberg/repos","events_url":"https://api.github.com/users/chanzuckerberg/events{/privacy}","received_events_url":"https://api.github.com/users/chanzuckerberg/received_events","type":"Organization","site_admin":false},"repo":{"id":182159589,"node_id":"MDEwOlJlcG9zaXRvcnkxODIxNTk1ODk=","name":"sorbet-rails","full_name":"chanzuckerberg/sorbet-rails","private":false,"owner":{"login":"chanzuckerberg","id":19917299,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5OTE3Mjk5","avatar_url":"https://avatars2.githubusercontent.com/u/19917299?v=4","gravatar_id":"","url":"https://api.github.com/users/chanzuckerberg","html_url":"https://github.com/chanzuckerberg","followers_url":"https://api.github.com/users/chanzuckerberg/followers","following_url":"https://api.github.com/users/chanzuckerberg/following{/other_user}","gists_url":"https://api.github.com/users/chanzuckerberg/gists{/gist_id}","starred_url":"https://api.github.com/users/chanzuckerberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chanzuckerberg/subscriptions","organizations_url":"https://api.github.com/users/chanzuckerberg/orgs","repos_url":"https://api.github.com/users/chanzuckerberg/repos","events_url":"https://api.github.com/users/chanzuckerberg/events{/privacy}","received_events_url":"https://api.github.com/users/chanzuckerberg/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/chanzuckerberg/sorbet-rails","description":"A set of tools to make the Sorbet typechecker work with Ruby on Rails seamlessly.","fork":false,"url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails","forks_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/forks","keys_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/teams","hooks_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/hooks","issue_events_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues/events{/number}","events_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/events","assignees_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/assignees{/user}","branches_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/branches{/branch}","tags_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/tags","blobs_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/statuses/{sha}","languages_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/languages","stargazers_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/stargazers","contributors_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/contributors","subscribers_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/subscribers","subscription_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/subscription","commits_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/contents/{+path}","compare_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/merges","archive_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/downloads","issues_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues{/number}","pulls_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls{/number}","milestones_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/milestones{/number}","notifications_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/labels{/name}","releases_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/releases{/id}","deployments_url":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/deployments","created_at":"2019-04-18T21:24:37Z","updated_at":"2019-08-29T21:09:26Z","pushed_at":"2019-08-29T21:09:38Z","git_url":"git://github.com/chanzuckerberg/sorbet-rails.git","ssh_url":"git@github.com:chanzuckerberg/sorbet-rails.git","clone_url":"https://github.com/chanzuckerberg/sorbet-rails.git","svn_url":"https://github.com/chanzuckerberg/sorbet-rails","homepage":"","size":1257,"stargazers_count":231,"watchers_count":231,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":13,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":16,"open_issues":13,"watchers":231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145"},"html":{"href":"https://github.com/chanzuckerberg/sorbet-rails/pull/145"},"issue":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues/145"},"comments":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/issues/145/comments"},"review_comments":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145/comments"},"review_comment":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/pulls/145/commits"},"statuses":{"href":"https://api.github.com/repos/chanzuckerberg/sorbet-rails/statuses/9b131d9029632ae6d2b362fc84720dc38deb164b"}},"author_association":"NONE"}}
{"actor":{"display_login":"deecewan"}}