Closed jbennett closed 1 year ago
I’m working with some XML that has a wrapping element with the same name as what I want for the inner element:
<foo> <bars> <bar id="1" /> <bar id="2" /> <bar id="3" /> </bars> </foo>
class Foo include HappyMappy wrap "bars" do has_many :bars, Bar # this doesn’t work end end
Passing the options through lets me give the wrapper a different name:
options
class Foo include HappyMappy wrap "bars_wrapper", tag: "bars" do has_many :bars, Bar end end
This allows access to the wrapper via foo.bars_wrapper and foo.bars directly
foo.bars_wrapper
foo.bars
Looks good. I can't believe there's no shortcut yet for this very common type of structure!
I’m working with some XML that has a wrapping element with the same name as what I want for the inner element:
Passing the
options
through lets me give the wrapper a different name:This allows access to the wrapper via
foo.bars_wrapper
andfoo.bars
directly