Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/cta_redux.rb

Class Method Summary collapse

Class Method Details

.wrap(object) ⇒ Array<Object>

Encloses the object with an array, if it is not already

Parameters:

  • object (Object)

    the object to enclose

Returns:

  • (Array<Object>)

    the object, enclosed in an array



61
62
63
64
65
66
67
68
69
# File 'lib/cta_redux.rb', line 61

def self.wrap(object)
  if object.nil?
    []
  elsif object.respond_to?(:to_ary)
    object.to_ary || [object]
  else
    [object]
  end
end