<p>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?</p>

<pre><code>profiles = ProfileResource.search(params)
output = profiles.collect do | profile |
    profile.to_hash
end
</code></pre>

<p>If profiles is a single object, I get a NoMethodError exception when I try to execute collect on that object.</p>

```
```
profiles = [ProfileResource.search(params)].flatten
output = profiles.collect do |profile|
    profile.to_hash
end
```
```