{"action":"created","issue":{"url":"https://api.github.com/repos/lotus/validations/issues/52","labels_url":"https://api.github.com/repos/lotus/validations/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/lotus/validations/issues/52/comments","events_url":"https://api.github.com/repos/lotus/validations/issues/52/events","html_url":"https://github.com/lotus/validations/issues/52","id":59801805,"number":52,"title":"Compatability with Lotus::Model/Entity","user":{"login":"plukevdh","id":16054,"avatar_url":"https://avatars.githubusercontent.com/u/16054?v=3","gravatar_id":"","url":"https://api.github.com/users/plukevdh","html_url":"https://github.com/plukevdh","followers_url":"https://api.github.com/users/plukevdh/followers","following_url":"https://api.github.com/users/plukevdh/following{/other_user}","gists_url":"https://api.github.com/users/plukevdh/gists{/gist_id}","starred_url":"https://api.github.com/users/plukevdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plukevdh/subscriptions","organizations_url":"https://api.github.com/users/plukevdh/orgs","repos_url":"https://api.github.com/users/plukevdh/repos","events_url":"https://api.github.com/users/plukevdh/events{/privacy}","received_events_url":"https://api.github.com/users/plukevdh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-04T14:07:36Z","updated_at":"2015-03-04T14:18:58Z","closed_at":null,"body":"Seeing consistency break down when including/using validations with `Lotus::Model`'s `Entity` mixin. The interface to a defined entity changes subtly so as to break expectations. See the following example:\r\n\r\n```ruby\r\nclass DummyModel\r\n  include Lotus::Entity\r\n  attributes :name, :email\r\nend\r\n# => [:name, :email]\r\n\r\nDummyModel.attributes\r\n# => #<Set: {:id, :name, :email}>\r\n\r\nm = DummyModel.new name: \"Luke\", email: \"test@me.com\"\r\n# => #<DummyModel:0x007fdc8d135b48 @email=\"test@me.com\", @name=\"Luke\">\r\n\r\nm.to_h\r\n# => {:id=>nil, :name=>\"Luke\", :email=>\"test@me.com\"}\r\n```\r\n\r\nVs the output of:\r\n\r\n```ruby\r\nclass OtherModel\r\n  include Lotus::Entity\r\n  include Lotus::Validations\r\n  attribute :email, presence: true\r\n  attribute :name, presence: true\r\nend\r\n#=> [:name]\r\n\r\nOtherModel.attributes\r\n#=> #<Set: {:id, :email, :name}>\r\n# Note, attributes includes the id here...\r\n\r\no = OtherModel.new name: \"Luke\", email: \"test@me.com\"\r\n#=> #<OtherModel:0x007fc03ba9c1f0 @attributes=#<Lotus::Utils::Attributes:0x007fc03ba9c1c8 @attributes={\"name\"=>\"Luke\", \"email\"=>\"test@me.com\"}>>\r\n# The internal structure (or at least the output of the inspect method) has changed\r\n\r\no.to_h\r\n#=> {:email=>\"test@me.com\", :name=>\"Luke\"}\r\n# What happened to the id field? `.attributes` tells me I should be able to expect it returned...\r\n```\r\n\r\nI can note that if I specify `attribute :id` at the same time as the validators, I can get it to return the id as well, but this is not consistent with how Lotus::Model acts."},"comment":{"url":"https://api.github.com/repos/lotus/validations/issues/comments/77164976","html_url":"https://github.com/lotus/validations/issues/52#issuecomment-77164976","issue_url":"https://api.github.com/repos/lotus/validations/issues/52","id":77164976,"user":{"login":"plukevdh","id":16054,"avatar_url":"https://avatars.githubusercontent.com/u/16054?v=3","gravatar_id":"","url":"https://api.github.com/users/plukevdh","html_url":"https://github.com/plukevdh","followers_url":"https://api.github.com/users/plukevdh/followers","following_url":"https://api.github.com/users/plukevdh/following{/other_user}","gists_url":"https://api.github.com/users/plukevdh/gists{/gist_id}","starred_url":"https://api.github.com/users/plukevdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plukevdh/subscriptions","organizations_url":"https://api.github.com/users/plukevdh/orgs","repos_url":"https://api.github.com/users/plukevdh/repos","events_url":"https://api.github.com/users/plukevdh/events{/privacy}","received_events_url":"https://api.github.com/users/plukevdh/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T14:18:58Z","updated_at":"2015-03-04T14:18:58Z","body":"One more note, that is more confusing as the docs indicate this ought to work:\r\n\r\n```ruby\r\nclass OneMore\r\n  include Lotus::Entity\r\n  include Lotus::Validations\r\n  attributes :name, :email\r\n  validates :email, presence: true\r\nend\r\n# => nil\r\n\r\nOneMore.attributes\r\n# => #<Set: {:id, :name, :email}>\r\n\r\nm = OneMore.new name: \"Luke\", email: \"test@me.com\"\r\n# => #<OneMore:0x007fc03bba6ff0 @attributes=#<Lotus::Utils::Attributes:0x007fc03bba6fc8 @attributes={\"email\"=>\"test@me.com\"}>>\r\n\r\nm.to_h\r\n# => {:email=>\"test@me.com\"}\r\n```"}}