{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18939","labels_url":"https://api.github.com/repos/rails/rails/issues/18939/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18939/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18939/events","html_url":"https://github.com/rails/rails/pull/18939","id":57681431,"number":18939,"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},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/actionpack","name":"actionpack","color":"FFF700"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/34","labels_url":"https://api.github.com/repos/rails/rails/milestones/34/labels","id":665192,"number":34,"title":"5.0.0","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":111,"closed_issues":61,"state":"open","created_at":"2014-05-21T00:58:22Z","updated_at":"2015-02-16T17:58:38Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-02-14T04:59:17Z","updated_at":"2015-02-16T19:19:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/18939","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"},"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."},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/74558978","html_url":"https://github.com/rails/rails/pull/18939#issuecomment-74558978","issue_url":"https://api.github.com/repos/rails/rails/issues/18939","id":74558978,"user":{"login":"dhh","id":2741,"avatar_url":"https://avatars.githubusercontent.com/u/2741?v=3","gravatar_id":"","url":"https://api.github.com/users/dhh","html_url":"https://github.com/dhh","followers_url":"https://api.github.com/users/dhh/followers","following_url":"https://api.github.com/users/dhh/following{/other_user}","gists_url":"https://api.github.com/users/dhh/gists{/gist_id}","starred_url":"https://api.github.com/users/dhh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhh/subscriptions","organizations_url":"https://api.github.com/users/dhh/orgs","repos_url":"https://api.github.com/users/dhh/repos","events_url":"https://api.github.com/users/dhh/events{/privacy}","received_events_url":"https://api.github.com/users/dhh/received_events","type":"User","site_admin":false},"created_at":"2015-02-16T19:19:10Z","updated_at":"2015-02-16T19:19:10Z","body":"I was thinking about StringInquirer taking a symbol, but then it’s not a symbol any more, it’s a string. I’d rather just be explicit and have a SymbolInquirer that inherits from Symbol.\n\n> On Feb 16, 2015, at 11:18, Eugene Gilburg <notifications@github.com> wrote:\n> \n> @dhh do you prefer two separate inquirer classes, one just for strings and one just for symbols, rather than soften StringInquirer to accept symbols (and just cast them to_s on initialize)?\n> \n> —\n> Reply to this email directly or view it on GitHub.\n> \n\n"}}