{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/24716080","id":24716080,"diff_hunk":"@@ -139,6 +141,33 @@ def negotiate_mime(order)\n         order.include?(Mime::ALL) ? format : nil\n       end\n \n+      class VariantInquirer # :nodoc:\n+        delegate :==, :each, :empty?, to: :variants\n+\n+        def initialize(variants = [])\n+          @variants = variants\n+        end\n+\n+        def any?(*candidates)\n+          (variants & candidates).any?\n+        end\n+\n+        def to_ary\n+          variants\n+        end\n+\n+        private\n+          attr_reader :variants","path":"actionpack/lib/action_dispatch/http/mime_negotiation.rb","position":57,"original_position":57,"commit_id":"26a752b00735c9b55a723da535770741d2b53760","original_commit_id":"26a752b00735c9b55a723da535770741d2b53760","user":{"login":"georgeclaghorn","id":94129,"avatar_url":"https://avatars.githubusercontent.com/u/94129?v=3","gravatar_id":"","url":"https://api.github.com/users/georgeclaghorn","html_url":"https://github.com/georgeclaghorn","followers_url":"https://api.github.com/users/georgeclaghorn/followers","following_url":"https://api.github.com/users/georgeclaghorn/following{/other_user}","gists_url":"https://api.github.com/users/georgeclaghorn/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeclaghorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeclaghorn/subscriptions","organizations_url":"https://api.github.com/users/georgeclaghorn/orgs","repos_url":"https://api.github.com/users/georgeclaghorn/repos","events_url":"https://api.github.com/users/georgeclaghorn/events{/privacy}","received_events_url":"https://api.github.com/users/georgeclaghorn/received_events","type":"User","site_admin":false},"body":"IMO, it shouldn't. It's intended for internal use only. Doesn't make sense to call `request.variant.variants`.","created_at":"2015-02-14T18:07:09Z","updated_at":"2015-02-14T18:07:09Z","html_url":"https://github.com/rails/rails/pull/18939#discussion_r24716080","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/18939","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/24716080"},"html":{"href":"https://github.com/rails/rails/pull/18939#discussion_r24716080"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/18939"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/18939","id":29315828,"html_url":"https://github.com/rails/rails/pull/18939","diff_url":"https://github.com/rails/rails/pull/18939.diff","patch_url":"https://github.com/rails/rails/pull/18939.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/18939","number":18939,"state":"open","locked":false,"title":"Provide friendlier access to request variants","user":{"login":"georgeclaghorn","id":94129,"avatar_url":"https://avatars.githubusercontent.com/u/94129?v=3","gravatar_id":"","url":"https://api.github.com/users/georgeclaghorn","html_url":"https://github.com/georgeclaghorn","followers_url":"https://api.github.com/users/georgeclaghorn/followers","following_url":"https://api.github.com/users/georgeclaghorn/following{/other_user}","gists_url":"https://api.github.com/users/georgeclaghorn/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeclaghorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeclaghorn/subscriptions","organizations_url":"https://api.github.com/users/georgeclaghorn/orgs","repos_url":"https://api.github.com/users/georgeclaghorn/repos","events_url":"https://api.github.com/users/georgeclaghorn/events{/privacy}","received_events_url":"https://api.github.com/users/georgeclaghorn/received_events","type":"User","site_admin":false},"body":"Currently, `request.variant` is a dumb reader for the underlying array used to store the request's variants. If you set the variant like so:\r\n\r\n```ruby\r\nrequest.variant = :phone\r\n```\r\n\r\n...then `request.variant` will return `[:phone]`. That can be cumbersome to deal with, since you have to check `request.variant.first == :phone`, `request.variant == [:phone]`, `request.variant.to_a.include?(:phone)`, etc.\r\n\r\nThis PR implements a friendlier interface:\r\n\r\n```ruby\r\nrequest.variant = :phone\r\nrequest.variant.phone?   # true\r\nrequest.variant.tablet?  # false\r\n\r\nrequest.variant = [:phone, :tablet]\r\nrequest.variant.phone?    # true\r\nrequest.variant.tablet?   # true\r\nrequest.variant.desktop?  # false\r\nrequest.variant.any?(:phone, :desktop)  # true\r\nrequest.variant.any?(:desktop, :watch)  # false\r\n```\r\n\r\nFixes #18933.","created_at":"2015-02-14T04:59:17Z","updated_at":"2015-02-14T18:07:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31cde08e238605fa72f95a07f86e58aeda96c42a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/18939/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/18939/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rails/rails/issues/18939/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/26a752b00735c9b55a723da535770741d2b53760","head":{"label":"georgeclaghorn:variant-inquiry","ref":"variant-inquiry","sha":"26a752b00735c9b55a723da535770741d2b53760","user":{"login":"georgeclaghorn","id":94129,"avatar_url":"https://avatars.githubusercontent.com/u/94129?v=3","gravatar_id":"","url":"https://api.github.com/users/georgeclaghorn","html_url":"https://github.com/georgeclaghorn","followers_url":"https://api.github.com/users/georgeclaghorn/followers","following_url":"https://api.github.com/users/georgeclaghorn/following{/other_user}","gists_url":"https://api.github.com/users/georgeclaghorn/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeclaghorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeclaghorn/subscriptions","organizations_url":"https://api.github.com/users/georgeclaghorn/orgs","repos_url":"https://api.github.com/users/georgeclaghorn/repos","events_url":"https://api.github.com/users/georgeclaghorn/events{/privacy}","received_events_url":"https://api.github.com/users/georgeclaghorn/received_events","type":"User","site_admin":false},"repo":{"id":7063992,"name":"rails","full_name":"georgeclaghorn/rails","owner":{"login":"georgeclaghorn","id":94129,"avatar_url":"https://avatars.githubusercontent.com/u/94129?v=3","gravatar_id":"","url":"https://api.github.com/users/georgeclaghorn","html_url":"https://github.com/georgeclaghorn","followers_url":"https://api.github.com/users/georgeclaghorn/followers","following_url":"https://api.github.com/users/georgeclaghorn/following{/other_user}","gists_url":"https://api.github.com/users/georgeclaghorn/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeclaghorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeclaghorn/subscriptions","organizations_url":"https://api.github.com/users/georgeclaghorn/orgs","repos_url":"https://api.github.com/users/georgeclaghorn/repos","events_url":"https://api.github.com/users/georgeclaghorn/events{/privacy}","received_events_url":"https://api.github.com/users/georgeclaghorn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/georgeclaghorn/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/georgeclaghorn/rails","forks_url":"https://api.github.com/repos/georgeclaghorn/rails/forks","keys_url":"https://api.github.com/repos/georgeclaghorn/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/georgeclaghorn/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/georgeclaghorn/rails/teams","hooks_url":"https://api.github.com/repos/georgeclaghorn/rails/hooks","issue_events_url":"https://api.github.com/repos/georgeclaghorn/rails/issues/events{/number}","events_url":"https://api.github.com/repos/georgeclaghorn/rails/events","assignees_url":"https://api.github.com/repos/georgeclaghorn/rails/assignees{/user}","branches_url":"https://api.github.com/repos/georgeclaghorn/rails/branches{/branch}","tags_url":"https://api.github.com/repos/georgeclaghorn/rails/tags","blobs_url":"https://api.github.com/repos/georgeclaghorn/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/georgeclaghorn/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/georgeclaghorn/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/georgeclaghorn/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/georgeclaghorn/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/georgeclaghorn/rails/languages","stargazers_url":"https://api.github.com/repos/georgeclaghorn/rails/stargazers","contributors_url":"https://api.github.com/repos/georgeclaghorn/rails/contributors","subscribers_url":"https://api.github.com/repos/georgeclaghorn/rails/subscribers","subscription_url":"https://api.github.com/repos/georgeclaghorn/rails/subscription","commits_url":"https://api.github.com/repos/georgeclaghorn/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/georgeclaghorn/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/georgeclaghorn/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/georgeclaghorn/rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/georgeclaghorn/rails/contents/{+path}","compare_url":"https://api.github.com/repos/georgeclaghorn/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/georgeclaghorn/rails/merges","archive_url":"https://api.github.com/repos/georgeclaghorn/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/georgeclaghorn/rails/downloads","issues_url":"https://api.github.com/repos/georgeclaghorn/rails/issues{/number}","pulls_url":"https://api.github.com/repos/georgeclaghorn/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/georgeclaghorn/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/georgeclaghorn/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/georgeclaghorn/rails/labels{/name}","releases_url":"https://api.github.com/repos/georgeclaghorn/rails/releases{/id}","created_at":"2012-12-08T04:42:19Z","updated_at":"2015-02-14T04:51:39Z","pushed_at":"2015-02-14T17:22:50Z","git_url":"git://github.com/georgeclaghorn/rails.git","ssh_url":"git@github.com:georgeclaghorn/rails.git","clone_url":"https://github.com/georgeclaghorn/rails.git","svn_url":"https://github.com/georgeclaghorn/rails","homepage":"http://rubyonrails.org","size":119753,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"rails:master","ref":"master","sha":"676d4ae787254e7842834e31204e5b7350261bbd","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-02-14T17:39:10Z","pushed_at":"2015-02-14T16:13:37Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":375097,"stargazers_count":24945,"watchers_count":24945,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9714,"mirror_url":null,"open_issues_count":756,"forks":9714,"open_issues":756,"watchers":24945,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/18939"},"html":{"href":"https://github.com/rails/rails/pull/18939"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/18939"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/18939/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/18939/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/18939/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/26a752b00735c9b55a723da535770741d2b53760"}}}}