-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatability with Lotus::Model/Entity #52
Comments
One more note, that is more confusing as the docs indicate this ought to work: class OneMore
include Lotus::Entity
include Lotus::Validations
attributes :name, :email
validates :email, presence: true
end
# => nil
OneMore.attributes
# => #<Set: {:id, :name, :email}>
m = OneMore.new name: "Luke", email: "test@me.com"
# => #<OneMore:0x007fc03bba6ff0 @attributes=#<Lotus::Utils::Attributes:0x007fc03bba6fc8 @attributes={"email"=>"test@me.com"}>>
m.to_h
# => {:email=>"test@me.com"} I assume, therefore that attributes are only returned if they're validated, which seems like an undesirable effect. |
@plukevdh Hello and thanks for sharing this problem. It absolutely deserves a fix. My plans were to include it with 0.3.0, but the release date is tomorrow, and we don't have enough time to do it now. I tried to write a patch on the fly, but it deserves a better investigation. I hope it won't be a problem if we postpone the fix a bit. Thank you 😄 |
@plukevdh Would you mind to check if the PR above fixes your issue? Thank you! |
Can do. Sorry for the delay. I'll update here as soon as I have a chance to run. |
@plukevdh We've merged that fixing PR because it looks good. Feel free to reopen this ticket if still doesn't work for you. Thanks. |
Seeing consistency break down when including/using validations with
Lotus::Model
'sEntity
mixin. The interface to a defined entity changes subtly so as to break expectations. See the following example:Vs the output of:
I 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.The text was updated successfully, but these errors were encountered: