-
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
XML changes: Avoid to set tag name from representer. Use as option instead. #140
base: master
Are you sure you want to change the base?
Conversation
Can you make an example how this helps, I didn't really understand it by looking at the tests. Thanks, man! |
@apotonick I added test case with example. So I think you will get the point. |
@apotonick any progress? |
Sorry to disappoint you, Alex, but XML support in Representable has a really low priority right now in my life - I promise you to look over it this week! ❤️ |
test/parse_strategy_test.rb
Outdated
@@ -17,11 +17,12 @@ class ParseStrategySyncTest < BaseTest | |||
|
|||
representer!(:module => mod, :name => :song_representer) do | |||
property :title | |||
self.representation_wrap = :song if format == :xml |
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.
This changes the test, can you please revert that? In this test I want to make sure representation_wrap
works and not :as
(at least that's what I remember). 😉
This PR adds the Is that correct? |
Yes, but as I understand |
Yeah, I remember |
@apotonick no. And inside |
@apotonick another thing. |
I sloooooowly start to remember this problem! It's great you came up with it! 👍 |
@apotonick So I fixed it property? I think not fully because still not possible to set wrapper tag for collections, but I think it could be possible through something like this: nested :songs do
collection :songs, as: :song, decorator: ::SongDecorator
end |
I am working on fixing this - it's a terrible mess in the current implementation and I might have to break the API. So, to sum up what you need. class InvoiceDecorator < Representable::Decorator
include XML
property :start_date, wrap: :start_date, decorator: DateDecorator
end Where the path would end up as |
@apotonick exactly! I think what my fix is not help you. |
I think there's two problems in the current XML implementation.
|
I have a case when I need to use same decorator for different properties. Just now I using subclasses for it what is annoying when you have a lot of same attribute types. With this PR I will be able to use
as
option for each property.