Just been looking at the documentation for Flag within dm-types. I can
see that the property of type Flag[] is assigned a type of integer in
the DB. It appears you can assign additional values to those you
specify by symbol as well as by overall amount of items.
With that I was wondering what the original intent was for stating the
properties values was if you can then add additional, non-stated, ones
without it complaining? Yes, validation can sit in front of the
various checks that may need to be made but I just wanted to clarify
the reason for the example syntax first.
Other than that a very useful addition to declaring properties :)
property :role, Flag[:admin, :editor, :translator, :tester]
rspec tests
specify "should be valid with :translator and :editor as :role" do
@model.attributes = valid_user_attributes
@model.role = [ :translator, :editor ]
@model.should be_valid
end
* PASS
specify "should be invalid with :anybody as :role" do
@model.attributes = valid_user_attributes
@model.role = [ :anybody ]
@model.should_not be_valid
end
* FAIL
specify "should be invalid when exceeding the original number
of :role values" do
@model.attributes = valid_user_attributes
@model.role =
[ :admin, :editor, :translator, :tester, :anybody ]
@model.should_not be_valid
end
* FAIL
--
You received this message because you are subscribed to the Google Groups
"DataMapper" 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/datamapper?hl=en.