Class: Shipwire::ParamConverter
- Inherits:
-
Object
- Object
- Shipwire::ParamConverter
- Defined in:
- lib/shipwire/param_converter.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params) ⇒ ParamConverter
constructor
A new instance of ParamConverter.
- #to_h ⇒ Object
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
#params ⇒ Object (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_h ⇒ Object
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 |