Hi,

I would like to have a boolean, that I can set to one of true/false/
nil (meaning something like yes/no/not set).

What I didn't realize at first was that boolean is wrapped in a
Hobo::Boolean and that attributes=() is wrapped in
convert_type_for_mass_assignment(), that rewrites a Hobo::Boolean from
an empty string or string 'false' or string '0' to false and anything
else to true.

Setting a boolean attribute directly (e.g. o.flag='') seems to follow
(at least partially) the "normal" Rails way of handling booleans,
where an empty string becomes nil (at least in Rails 2.3.8, and just
what I wanted), but also some Hobo-Magic, that wraps a boolean into
Hobo::Boolean, which produces slight inconsistencies:

o = SomeClass.new
o.flag=''
o.flag     # => nil
o.read_attribute(:flag)  # => false
o.instance_variable_get(:@attributes)   # => ....'flag' => ''
o.instance_variable_get(:@attributes_cache)   # => ....'flag' => nil

Any idea on how I could achieve what I want? Should I go for my own
Hobo rich type?

Regards, Bernhard

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to