I have this object:
object.name
Sometimes name could be an array, sometimes it could be a string and sometimes an empty string. And so I assumed I could do something like this:
object.name do |name|
name.is_a?(Array) ? name.join(' ') : name
end.presence
But this does not work, I can access name in the block but anything I do to it does not return.
What am I actually doing by passing name into a block like that? and how can I make this ruby lovely and work?
Thanks!
#namemethod takes a block ? First check this .namehave multiple possible types? If you want to accept multiple types to set the value, that will mean you will want a different solution than if it inherently can hold multiple types of data.