{"action":"created","issue":{"url":"https://api.github.com/repos/remiprev/her/issues/381","labels_url":"https://api.github.com/repos/remiprev/her/issues/381/labels{/name}","comments_url":"https://api.github.com/repos/remiprev/her/issues/381/comments","events_url":"https://api.github.com/repos/remiprev/her/issues/381/events","html_url":"https://github.com/remiprev/her/pull/381","id":113563106,"number":381,"title":"Change default behavior of comparison operator like Activerecord","user":{"login":"hmatsuda","id":1421898,"avatar_url":"https://avatars.githubusercontent.com/u/1421898?v=3","gravatar_id":"","url":"https://api.github.com/users/hmatsuda","html_url":"https://github.com/hmatsuda","followers_url":"https://api.github.com/users/hmatsuda/followers","following_url":"https://api.github.com/users/hmatsuda/following{/other_user}","gists_url":"https://api.github.com/users/hmatsuda/gists{/gist_id}","starred_url":"https://api.github.com/users/hmatsuda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmatsuda/subscriptions","organizations_url":"https://api.github.com/users/hmatsuda/orgs","repos_url":"https://api.github.com/users/hmatsuda/repos","events_url":"https://api.github.com/users/hmatsuda/events{/privacy}","received_events_url":"https://api.github.com/users/hmatsuda/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-27T11:33:21Z","updated_at":"2015-11-13T06:35:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/remiprev/her/pulls/381","html_url":"https://github.com/remiprev/her/pull/381","diff_url":"https://github.com/remiprev/her/pull/381.diff","patch_url":"https://github.com/remiprev/her/pull/381.patch"},"body":"her's comparison operator returns false if one object is find from relational methods but Activerecord returns true in same situations.\r\n\r\n```\r\nclass CustomerResource\r\n  include Her::Model\r\n  has_many :orders\r\nend\r\n\r\nclass OrderResource\r\n  include Her::Model\r\n  belongs_to :customer\r\nend\r\n\r\n> OrderResource.find(1) == OrderResource.find(1)\r\ntrue\r\n> CustomerResource.orders.find(1) == OrderResource.find(1)\r\nfalse\r\n\r\nclass Customer < ActiveRecord::Base\r\n  has_many :orders\r\nend\r\n\r\nclass Order < ActiveRecord::Base\r\n  belongs_to :customer\r\nend\r\n\r\n> Order.find(1) == Order.find(1)\r\ntrue\r\n> Customer.orders.find(1) == Order.find(1)\r\ntrue\r\n\r\n```\r\n\r\nMain cause of that object which includes Her::Model has relation attributes when find from relational resource.\r\n\r\n```\r\nCustomer.orders.find(1).attributes[:customer_resource]\r\n<CustomerResource(cusotomers/1) price=\"1000\" created_at=\"2015-10-27T17:01:19.000+09:00\" updated_at=\"2015-10-27T17:02:47.000+09:00\" id=1>\r\n```\r\n\r\nI think it should be better if her's comparison method works same as Activerecord one.\r\nhttps://github.com/rails/rails/blob/master/activerecord/lib/active_record/core.rb#L409-L414"},"comment":{"url":"https://api.github.com/repos/remiprev/her/issues/comments/156339776","html_url":"https://github.com/remiprev/her/pull/381#issuecomment-156339776","issue_url":"https://api.github.com/repos/remiprev/her/issues/381","id":156339776,"user":{"login":"hubert","id":106995,"avatar_url":"https://avatars.githubusercontent.com/u/106995?v=3","gravatar_id":"","url":"https://api.github.com/users/hubert","html_url":"https://github.com/hubert","followers_url":"https://api.github.com/users/hubert/followers","following_url":"https://api.github.com/users/hubert/following{/other_user}","gists_url":"https://api.github.com/users/hubert/gists{/gist_id}","starred_url":"https://api.github.com/users/hubert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hubert/subscriptions","organizations_url":"https://api.github.com/users/hubert/orgs","repos_url":"https://api.github.com/users/hubert/repos","events_url":"https://api.github.com/users/hubert/events{/privacy}","received_events_url":"https://api.github.com/users/hubert/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T06:35:56Z","updated_at":"2015-11-13T06:35:56Z","body":"thanks for the contribution @hmatsuda.\r\n\r\nit doesn't look like the way == is written now is perfect, but the way you've rewritten ==, it would be pretty easy to get false positives.\r\n\r\n```\r\nclass Foo; include Her::Model; end\r\n\r\nclass Bar: include Her::Model; end\r\n\r\n> Foo.new(id: 1) == Bar.new(id: 1)\r\ntrue\r\n```"}}