Skip to content
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

Error in xml builder - array with nil values create empty tags #39

Closed
kristianmandrup opened this issue Jan 29, 2014 · 2 comments
Closed

Comments

@kristianmandrup
Copy link

Gyoko.xml "attribute" => [nil, nil, {}]

IMO should output only one empty <attribute/> element. In my case it outputted 3.
I think all nils should be ignored (f.ex by using compact internally). Just my take.
Cheers!

@tjarratt
Copy link
Contributor

tjarratt commented Feb 1, 2014

Interesting issue -- was this issue driven by some case where you passed the results of some method to gyoku, @kristianmandrup?

eg:

def slot_machine
  return rand > 0.5 ? nil : "JACKPOT"
end

def craftSomeXML
  Gyoku.xml "attribute" => [slot_machine, slot_machine, {}]
end

Mostly, I'm just curious how this issue came up. It's not immediately obvious to me how handling nil in this manner is an improvement to end users. FWIW, this behavior is actually documented in the README:

NilClass objects are converted to xsi:nil tags

@tjarratt
Copy link
Contributor

Closing as Won't Fix for now. I'm open to changing this behavior in the next version of Gyoku, however, so if you're reading this and would like this behavior, please speak up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants