XML changes: Avoid to set tag name from representer. Use as option instead.#140
XML changes: Avoid to set tag name from representer. Use as option instead.#140simonoff wants to merge 1 commit intotrailblazer:masterfrom
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
There was a problem hiding this comment.
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
endWhere 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
asoption for each property.