{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/24882","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/24882/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/24882/comments","events_url":"https://api.github.com/repos/rails/rails/issues/24882/events","html_url":"https://github.com/rails/rails/pull/24882","id":153393763,"number":24882,"title":"string inquiry should be case insensitive","user":{"login":"ignatiusreza","id":667726,"avatar_url":"https://avatars.githubusercontent.com/u/667726?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatiusreza","html_url":"https://github.com/ignatiusreza","followers_url":"https://api.github.com/users/ignatiusreza/followers","following_url":"https://api.github.com/users/ignatiusreza/following{/other_user}","gists_url":"https://api.github.com/users/ignatiusreza/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatiusreza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatiusreza/subscriptions","organizations_url":"https://api.github.com/users/ignatiusreza/orgs","repos_url":"https://api.github.com/users/ignatiusreza/repos","events_url":"https://api.github.com/users/ignatiusreza/events{/privacy}","received_events_url":"https://api.github.com/users/ignatiusreza/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-06T07:21:10Z","updated_at":"2016-05-06T11:15:42Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/24882","html_url":"https://github.com/rails/rails/pull/24882","diff_url":"https://github.com/rails/rails/pull/24882.diff","patch_url":"https://github.com/rails/rails/pull/24882.patch"},"body":"### Summary\r\n\r\nExisting implementation of string inquiry is case sensitive, hence `'GitHub'.inquiry.github?` will return false while `'GitHub'.inquiry.GitHub?` will return true.. which is surprising, given that method in ruby are (mostly) written in `snake_case`\r\n\r\n### Other Information\r\n\r\nBased on the benchmark written below, performance doesn't seems to be impacted:\r\n\r\n```\r\nCalculating -------------------------------------\r\n             inquiry    79.808k i/100ms\r\n inquiry ignore_case    77.026k i/100ms\r\n-------------------------------------------------\r\n             inquiry      1.603M (± 3.5%) i/s -      8.061M\r\n inquiry ignore_case      1.517M (± 4.5%) i/s -      7.626M\r\n```\r\n\r\nBenchmark code:\r\n```rb\r\nrequire 'benchmark/ips'\r\n\r\nclass StringInquirer < String\r\n  private\r\n\r\n    def respond_to_missing?(method_name, include_private = false)\r\n      method_name[-1] == '?'\r\n    end\r\n\r\n    def method_missing(method_name, *arguments)\r\n      if method_name[-1] == '?'\r\n        self == method_name[0..-2]\r\n      else\r\n        super\r\n      end\r\n    end\r\nend\r\n\r\nclass StringInquirerIgnoreCase < String\r\n  private\r\n\r\n    def respond_to_missing?(method_name, include_private = false)\r\n      method_name[-1] == '?'\r\n    end\r\n\r\n    def method_missing(method_name, *arguments)\r\n      if method_name[-1] == '?'\r\n        self.casecmp(method_name[0..-2]) == 0\r\n      else\r\n        super\r\n      end\r\n    end\r\nend\r\n\r\nstring        = StringInquirer.new('production')\r\nstring_ignore = StringInquirerIgnoreCase.new('Production')\r\n\r\n\r\nBenchmark.ips do |x|\r\n  x.report('inquiry')             { string.production? }\r\n  x.report('inquiry ignore_case') { string_ignore.production? }\r\nend\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/217413817","html_url":"https://github.com/rails/rails/pull/24882#issuecomment-217413817","issue_url":"https://api.github.com/repos/rails/rails/issues/24882","id":217413817,"user":{"login":"ignatiusreza","id":667726,"avatar_url":"https://avatars.githubusercontent.com/u/667726?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatiusreza","html_url":"https://github.com/ignatiusreza","followers_url":"https://api.github.com/users/ignatiusreza/followers","following_url":"https://api.github.com/users/ignatiusreza/following{/other_user}","gists_url":"https://api.github.com/users/ignatiusreza/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatiusreza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatiusreza/subscriptions","organizations_url":"https://api.github.com/users/ignatiusreza/orgs","repos_url":"https://api.github.com/users/ignatiusreza/repos","events_url":"https://api.github.com/users/ignatiusreza/events{/privacy}","received_events_url":"https://api.github.com/users/ignatiusreza/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T11:15:42Z","updated_at":"2016-05-06T11:15:42Z","body":"we first noticed this issue when inquiring against country name -- country list are stored in db.. e.g.\r\n\r\n```\r\ncountry = Country.new(name: 'Japan')\r\ncountry.name.inquiry.japan?\r\n\r\n# shorten with delegate :inquiry, to: :name\r\n\r\ncountry.inquiry.japan?\r\n```\r\n\r\nand then, we found similar needs with 3rd party provider name, e.g. `PayPal` to be inquired as `paypal?`"}}