I have a method that can return either a single object or a collection of objects. I want to be able to run object.collect on the result of that method whether or not it is a single object or a collection already. How can i do this?
profiles = ProfileResource.search(params)
output = profiles.collect do | profile |
profile.to_hash
end
If profiles is a single object, I get a NoMethodError exception when I try to execute collect on that object.