Skip to content

Instantly share code, notes, and snippets.

@aratak
Created March 24, 2014 15:47
Show Gist options
  • Save aratak/9742918 to your computer and use it in GitHub Desktop.
Save aratak/9742918 to your computer and use it in GitHub Desktop.
Array wrap
# config/initializers/array_wrap.rb
class Array
def self.wrap(object)
if object.nil?
[]
elsif object.respond_to?(:to_ary)
object.to_ary || [object]
else
[object]
end
end
end unless Array.respond_to? :wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment