Unexpected Mail instance categories
, categories=
behavior
#86
Labels
status: help wanted
requesting help from the community
type: community enhancement
feature request not on Twilio's roadmap
Issue Summary
SendGrid::Mail
categories behavior makes it too easy to set empty values.Steps to Reproduce
Instantiate a new instance
I know it will end up being an Arrary, so try to add something to it...
Oh,
categories
starts nil. I guess we need to instantiate it?An Array with
nil
in it. ???More misleading is that if someone expects it to accept the String category, it will not complain, it will just add
nil
Despite its own awareness that it is an Array and its delegation of methods, it doesn't actually let me treat it like an array, so I don't have a clear way of fixing this.
You could improve this by doing two things:
Sendgrid::Mail
should setcategories
to an empty Array. If nothing else, that would let callers know to treat it like an array and avoidcategories=
in the first place.https://github.com/sendgrid/sendgrid-ruby/blob/master/lib/sendgrid/helpers/mail/mail.rb#L908
categories=
. I don't think that what you have defined works at all. When you call[string]
on a String, you just select that pattern from the string. So if someone did do this:This is also why calling
categories=
results innil
entries: it converts everything to a String withto_json
and thenwhatever_your_string_is['categories']
always returns nil.Technical details:
The text was updated successfully, but these errors were encountered: