Mailinglist Archive: yast-devel (163 mails)

< Previous Next >
Re: [yast-devel] WebYaST: how to pass empty string to rest-service?
  • From: josef reidinger <jreidinger@xxxxxxx>
  • Date: Wed, 16 Sep 2009 10:32:22 +0200
  • Message-id: <4AB0A296.3000002@xxxxxxx>
Martin Vidner napsal(a):
On Wed, Sep 16, 2009 at 09:47:46AM +0200, Jiří Suchomel wrote:
in administrator module I have a POST request from client that contains the
information about root password and mail aliases. Sometimes I would like to
pass an empty value (for mail aliases, to reset it to no alias) and to
distinguish the empty value from nil (nil has a meaning do not try to save
this, while empty means save empty).

Rails will not let you :-(
at least for hash values.

Hash#from_xml has
# blank or nil parsed values are represented by nil
elsif value.blank? || value['nil'] == 'true'

"An object is blank if it‘s false, empty, or a
whitespace string. For example, "", " ", nil, [], and {} are blank."

BTW, Hash#from_xml also looks if an array has a single element and
unwraps it. Helpful, huh?

If you cannot adapt your API to deal with this, I suggest writing
(finding?) a stricter from_xml.

I think that for this case it is over-engineering. Because it is email,
you have many values which should identify empty string. So I think you
can set email to "NONE" and catch this value in backend.
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >