Class: Seahorse::Client::ParamConverter

Inherits:
Object
  • Object
show all
Defined in:
aws-sdk-core/lib/seahorse/client/param_converter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shape) ⇒ ParamConverter

Returns a new instance of ParamConverter

Parameters:


15
16
17
# File 'aws-sdk-core/lib/seahorse/client/param_converter.rb', line 15

def initialize(shape)
  @shape = shape
end

Class Method Details

.add(shape_class, value_class, converter = nil, &block) ⇒ void

This method returns an undefined value.

Registers a new value converter. Converters run in the context of a shape and value class.

# add a converter that stringifies integers
shape_class = Seahorse::Model::Shapes::StringShape
ParamConverter.add(shape_class, Integer) { |i| i.to_s }

Parameters:

  • shape_class (Class<Model::Shapes::Shape>)
  • value_class (Class)
  • converter (#call) (defaults to: nil)

    (nil) An object that responds to #call accepting a single argument. This function should perform the value conversion if possible, returning the result. If the conversion is not possible, the original value should be returned.


98
99
100
# File 'aws-sdk-core/lib/seahorse/client/param_converter.rb', line 98

def add(shape_class, value_class, converter = nil, &block)
  @converters[shape_class][value_class] = converter || block
end

.convert(shape, params) ⇒ Hash

Parameters:

  • shape (Model::Shapes::InputShape)
  • params (Hash)

Returns:

  • (Hash)

79
80
81
# File 'aws-sdk-core/lib/seahorse/client/param_converter.rb', line 79

def convert(shape, params)
  new(shape).convert(params)
end

Instance Method Details

#convert(params) ⇒ Hash

Parameters:

  • params (Hash)

Returns:

  • (Hash)

21
22
23
# File 'aws-sdk-core/lib/seahorse/client/param_converter.rb', line 21

def convert(params)
  structure(@shape, params)
end