module Pakyow::Support::Refinements::Array::Ensurable

Public Instance Methods

ensure(object) click to toggle source

Ensures that object is an array, converting it if necessary. This was added to safely wrap hashes, because +Array(hash)+ converts into an array of key/value pairs.

# File lib/pakyow/support/core_refinements/array/ensurable.rb, line 13
def ensure(object)
  if object.respond_to?(:to_ary)
    object.to_ary
  else
    [object]
  end
end