bldr icon indicating copy to clipboard operation
bldr copied to clipboard

attribute option to indicate if a blank values' key should be included in the output

Open ajsharp opened this issue 13 years ago • 7 comments

Often times, when an attribute has a nil/null value, we don't want to include the key at all in response. An option to the attribute method like :include_blank => false would be helpful, as we run into this problem quite a bit. Of course, the default would remain true.

ajsharp avatar Oct 11 '11 17:10 ajsharp

Is there a global setting as well?

ian avatar Oct 11 '11 17:10 ian

Would prefer something a little more semantic, like :include_blank_attributes

ian avatar Oct 11 '11 17:10 ian

There is not currently, and I wasn't envisioning one -- it seems too implementation specific to be useful at a global level, though I guess it wouldn't hurt to have one...

ajsharp avatar Oct 11 '11 17:10 ajsharp

Sorry, last arg was from an object/collection standpoint.

ian avatar Oct 11 '11 17:10 ian

Would prefer something a little more semantic, like :include_blank_attributes

If this were an option passed to the attribute method, I think :include_blank_attributes would be a little redundant.

ajsharp avatar Oct 11 '11 17:10 ajsharp

So maybe you're right, as a start just add the include_blank => true and we can add options higher up the stack if a general control of objects is necessary.

ian avatar Oct 11 '11 17:10 ian

Sounds good. This should be pretty trivial to implement.

ajsharp avatar Oct 11 '11 17:10 ajsharp