:zero_value doesn't work
I have this code
bitmask :p_type, :as => [:a, :b, :c], :zero_value => :t, :null => false
but if I do
Car.first.post_type (which is 0) I get []
Is it me or a bug?
the intent of the zero value attribute was to be able to explicitly set a field to zero, since assigning an empty array OR's in the contents of the array rather than setting it to zero...
the getter returning an empty array should be interpreted as "no bits are set"; by returning the "zero value" in that set, it would make the normal meaning of bits being set (or not) be more difficult to ascertain IMO...
so how do I have a value for 0b000 in this case?
i guess it depends on how you want to use it...
prior to the (relatively) recent introduction of the zero value, testing for "no bits set" was and is a simple matter of testing a "value" for empty (e.g., value.empty?) or even equality to an empty array (e.g., value == [])...
as i recall, a key motivation for introducing this concept was ensure that the form data returning to a controller to set a bitmask field could have SOMETHING in the array that guaranteed its presence; in my case, i had some forms that did and did not include setting of this attribute, so i needed the zero value to ensure that if the user (for example) unchecked all the checkboxes corresponding to bits that the zero value would ensure that the bitmask got set to zero when performing an "update_attributes" call on my model...
hope that helps :-)
so what is :null => false then?