{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/3816","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/3816/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/3816/comments","events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/3816/events","html_url":"https://github.com/ManageIQ/manageiq/pull/3816","id":100428870,"number":3816,"title":"Allow MiqHashStruct to properly respond to :try","user":{"login":"brandondunne","id":651659,"avatar_url":"https://avatars.githubusercontent.com/u/651659?v=3","gravatar_id":"","url":"https://api.github.com/users/brandondunne","html_url":"https://github.com/brandondunne","followers_url":"https://api.github.com/users/brandondunne/followers","following_url":"https://api.github.com/users/brandondunne/following{/other_user}","gists_url":"https://api.github.com/users/brandondunne/gists{/gist_id}","starred_url":"https://api.github.com/users/brandondunne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandondunne/subscriptions","organizations_url":"https://api.github.com/users/brandondunne/orgs","repos_url":"https://api.github.com/users/brandondunne/repos","events_url":"https://api.github.com/users/brandondunne/events{/privacy}","received_events_url":"https://api.github.com/users/brandondunne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-11T22:51:25Z","updated_at":"2015-08-11T23:40:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/3816","html_url":"https://github.com/ManageIQ/manageiq/pull/3816","diff_url":"https://github.com/ManageIQ/manageiq/pull/3816.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/3816.patch"},"body":"Before:\r\n```\r\nirb(main):001:0> require './gems/pending/util/miq-hash_struct'\r\n=> true\r\nirb(main):002:0> hs = MiqHashStruct.new(:id => 1)\r\n=> #<MiqHashStruct:0x007f8a52c41088 @hash={:id=>1}, @key_type=Symbol>\r\nirb(main):003:0> hs.try(:id)\r\n=> nil\r\nirb(main):004:0> hs.id\r\n=> 1\r\nirb(main):005:0> hs.abc\r\n=> nil\r\n```\r\n\r\nAfter:\r\n```\r\nirb(main):001:0> require './gems/pending/util/miq-hash_struct'\r\n=> true\r\nirb(main):002:0> hs = MiqHashStruct.new(:id => 1)\r\n=> #<MiqHashStruct:0x007f049534d2a8 @hash={:id=>1}, @key_type=Symbol>\r\nirb(main):003:0> hs.try(:id)\r\n=> 1\r\nirb(main):004:0> hs.id\r\n=> 1\r\nirb(main):005:0> hs.abc\r\n=> nil\r\n```\r\nhttps://bugzilla.redhat.com/show_bug.cgi?id=1250087"},"comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments/130112588","html_url":"https://github.com/ManageIQ/manageiq/pull/3816#issuecomment-130112588","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/3816","id":130112588,"user":{"login":"gmcculloug","id":2591569,"avatar_url":"https://avatars.githubusercontent.com/u/2591569?v=3","gravatar_id":"","url":"https://api.github.com/users/gmcculloug","html_url":"https://github.com/gmcculloug","followers_url":"https://api.github.com/users/gmcculloug/followers","following_url":"https://api.github.com/users/gmcculloug/following{/other_user}","gists_url":"https://api.github.com/users/gmcculloug/gists{/gist_id}","starred_url":"https://api.github.com/users/gmcculloug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmcculloug/subscriptions","organizations_url":"https://api.github.com/users/gmcculloug/orgs","repos_url":"https://api.github.com/users/gmcculloug/repos","events_url":"https://api.github.com/users/gmcculloug/events{/privacy}","received_events_url":"https://api.github.com/users/gmcculloug/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T23:40:42Z","updated_at":"2015-08-11T23:40:42Z","body":"@brandondunne Implementing `try` through missing method would only work here for keys that are defined in the in the internal hash but would return nil for other object methods.\r\n\r\nFor example:\r\n```\r\nirb(main):002:0> h = MiqHashStruct.new(:test => 1)\r\n=> #<MiqHashStruct:0x007f944b883f88 @hash={:test=>1}, @key_type=Symbol>\r\nirb(main):003:0> h.try(:object_id)\r\n=> nil\r\n```\r\n\r\nUsing `public_send` instead allows both to work: `alias :try :public_send`"}}