-
Notifications
You must be signed in to change notification settings - Fork 108
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
Implement Representable::Object#to_object #266
base: master
Are you sure you want to change the base?
Implement Representable::Object#to_object #266
Conversation
0d0e09c
to
d81728a
Compare
README.md
Outdated
- `Representable::JSON#to_json` | ||
- `Representable::JSON#to_hash` (provides a hash instead of string) | ||
- `Representable::Hash#to_hash` | ||
- `Representable::Object#to_object` (provides a Struct-based object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then it should be to_struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we make the object type configurable and Struct
is one of the possible targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. But having a to_struct shortcut is good too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, module Struct
and to_struct
fit more, as to_object
is too vague. Moved the new code to a new module.
Frankly, I'm kinda confused about configurable object type
with Struct as one of the possible targets. What other possible target there could be..? OpenStruct / AnyCustomUserClassPassedAsArgument? I feel like Struct is sufficient and there's no need for other options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object can return the original object such as ActiveRecord model or a Poro with it attributes set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly, I'm kinda confused about
configurable object type
with Struct as one of the possible targets. What other possible target there could be..?
Imagine a project with Domain::Song
, Domain::Song::Duration
, Domain::Artist
, etc. People might want to transform an object to another domain object?!
c8ce696
to
f548bd1
Compare
f548bd1
to
fcf985d
Compare
Please see Issue#267