I'm not sure what a good name for this really is, or the best way for it to work, but I was just writing some tests, and expecting model.attributes to return all my flags as individual Boolean attribute values, which of course, it did not :)
My flag field is called setup_steps so I figured out I could rewrite the test to use selected_setup_steps, but I still think a method to retrieve the flag values in the format of regular attributes (the same way you can set them) would be useful (i.e. { flag1: true, flag2: true, flag3: false })
What I'm not sure about is whether it makes more sense for that to be a model-wide method, like model.attributes_with_flags which would return all the normal attributes, plus additional attributes for each defined flag (regardless of how many flag fields are defined), or to make one method per flag field, like model.setup_steps_as_attributes or something to that effect... that one would be marginally easier to implement at least. Any opinion?
I'm not sure what a good name for this really is, or the best way for it to work, but I was just writing some tests, and expecting
model.attributesto return all my flags as individual Boolean attribute values, which of course, it did not :)My flag field is called
setup_stepsso I figured out I could rewrite the test to useselected_setup_steps, but I still think a method to retrieve the flag values in the format of regular attributes (the same way you can set them) would be useful (i.e.{ flag1: true, flag2: true, flag3: false })What I'm not sure about is whether it makes more sense for that to be a model-wide method, like
model.attributes_with_flagswhich would return all the normal attributes, plus additional attributes for each defined flag (regardless of how many flag fields are defined), or to make one method per flag field, likemodel.setup_steps_as_attributesor something to that effect... that one would be marginally easier to implement at least. Any opinion?