Thanks for the reply but to be honest I'm not really sure as there appears to be some confusion, in my mind anyway, created by the example syntax on http://datamapper.org/docs/dm_more/types... however, I may of course be over complicating matters as well.
Personally I would have thought firstly if it was a bitwise mapping, i.e., digit maps to a named value or key, and ideally once you've declared any base values, e.g. Flag[:admin, :editor, :translator, :tester], should be centrally controlled and fixed / restricted during any subsequent create or update actions and as such cannot then mutate. For example, :role type :nobody doesn't exist in the original list so should it still be accepted? Secondly, you shouldn't really be able to exceed the total number of initial values that you've specified (?), but it turns out that you can. These two questions arose from using the Flag[] type which, to be perfectly honest, I'm not sure if these are bugs or not, or just reasonable behavior... Anyway, as I needed to restrict the possible entries to only those I specified I added a validates_with_method to the model. This hopefully stops any deviation from the original list and contains the situation. This pastie shows the model and rspec tests for that stage of development which I "had" reached: http://pastie.org/1055304 So, that was all good once I added in my own validation, however, on adding a few rspec tests for the merb-auth backed authentication things became quite strange again. In order to successfully test the authentication, and have it return the pre-defined :role value I passed - which was part of the default set of valid credentials, without the :role value /disappearing/ I had to specify the roles explicitly in the model again, i.e., property :role, Flag[:admin, :editor, :translator, :tester] This pastie shows what I now "have": http://pastie.org/1055330 I'm still none the wiser about what I can really expect from Flag[], although I see it as damned handy for this usage, and whether I've stumbled on bugs or not.. If this type of behavior for Flag[] suggests problems still please let me know and I'll fire off a bug report. On 22 July, 04:37, Kevin <[email protected]> wrote: > Ah, so flag assigns a bit to each flag and can add them together/etc > to allow multiple flags to be set? > > Your failing test seems to be a bug with it, eh? Add a ticket to the > lighthouse?http://datamapper.lighthouseapp.com/projects/20609-datamapper/overview -- 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.
