Class: ConvenientService::Utils::Array::Wrap

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/array/wrap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(object) ⇒ void

Parameters:

  • object (Object)

    Can be any type.



22
23
24
# File 'lib/convenient_service/utils/array/wrap.rb', line 22

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



16
17
18
# File 'lib/convenient_service/utils/array/wrap.rb', line 16

def object
  @object
end

#padObject (readonly)

Returns Can be any type.

Returns:

  • (Object)

    Can be any type.



16
# File 'lib/convenient_service/utils/array/wrap.rb', line 16

attr_reader :object

Instance Method Details

#callArray

Returns:



33
34
35
36
37
38
39
40
41
# File 'lib/convenient_service/utils/array/wrap.rb', line 33

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