Class: Shipwire::ParamConverter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ ParamConverter

Returns a new instance of ParamConverter.



5
6
7
8
9
10
11
12
13
# File 'lib/shipwire/param_converter.rb', line 5

def initialize(params)
  if params.is_a?(Array)
    @params = params.each_with_object([]) do |item, hsh|
      hsh << recursively_struct(item)
    end
  else
    @params = recursively_struct(params)
  end
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/shipwire/param_converter.rb', line 3

def params
  @params
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
23
# File 'lib/shipwire/param_converter.rb', line 15

def to_h
  if params.is_a?(Array)
    params.each_with_object([]) do |item, hsh|
      hsh << with_object(item)
    end
  else
    with_object(params)
  end
end