
dm-types Flag api issue
Reported by bgentry | November 17th, 2009 @ 06:24 PM | in 1.0.0
To me it seems inconsistent and unintuitive that the Flag type will return a symbol when there is only one flag set, and return an array when there are two or more flags.
Example:
property :state, Flag[ :new, :urgent, :closed ], :default =>
:new
model.state will return :new in the default state.
If I set model.state = [:new, :urgent], then naturally it will return an array.
I would expect that this should return an array in all cases. Any other thoughts?
Comments and changes to this ticket
-
Dan Kubb (dkubb) November 18th, 2009 @ 06:06 AM
- State changed from new to unconfirmed
I agree, the current API is inconsistent. It should return an Array always so that any code handling this does not need to wrap the model.state with Array().
-
Dan Kubb (dkubb) May 22nd, 2010 @ 01:40 AM
- Assigned user set to Piotr Solnica (solnic)
-
Dan Kubb (dkubb) May 26th, 2010 @ 02:06 AM
- Milestone set to 1.0.0
-
Piotr Solnica (solnic) May 26th, 2010 @ 03:53 AM
- State changed from unconfirmed to accepted
-
Piotr Solnica (solnic) June 1st, 2010 @ 04:56 PM
- State changed from accepted to resolved
(from [5dc78ae4e1f1ae675ba05a6726d5a7f134b7dfb9]) Flag#typecast should always return the value in an array, that makes the type's behaviour consistent when :default => :something is specified.
[#1128 state:resolved] http://github.com/datamapper/dm-types/commit/5dc78ae4e1f1ae675ba05a...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Referenced by
-
1161 dm-types Flag fails to persist values assigned with the left shift operator. See also:#1128
-
1128 dm-types Flag api issue [#1128 state:resolved] http://github.com/datamapper/dm-t...
-
1161 dm-types Flag fails to persist values assigned with the left shift operator. Because the Flag type contains multiple values, and is re...