Sha256: b5f62e218055867b901a4fc3d874e7e3903bc488f9a758990a88800424ffa7c5

Contents?: true

Size: 354 Bytes

Versions: 2

Compression:

Stored size: 354 Bytes

Contents

class Array
  # Wraps the object in an Array unless it's an Array.  Converts the
  # object to an Array using #to_ary if it implements that.
  def self.wrap(object)
    case object
    when nil
      []
    when self
      object
    else
      if object.respond_to?(:to_ary)
        object.to_ary
      else
        [object]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
activesupport-3.0.pre lib/active_support/core_ext/array/wrap.rb
recliner-0.0.1 vendor/activesupport/lib/active_support/core_ext/array/wrap.rb