Class: Seahorse::Client::ParamConverter
- Inherits:
-
Object
- Object
- Seahorse::Client::ParamConverter
- Defined in:
- lib/seahorse/client/param_converter.rb
Class Method Summary collapse
-
.add(shape_class, value_class, converter = nil, &block) ⇒ void
Registers a new value converter.
- .c(shape, value) ⇒ Object private
- .convert(shape, params) ⇒ Hash
Instance Method Summary collapse
- #convert(params) ⇒ Hash
-
#initialize(shape) ⇒ ParamConverter
constructor
A new instance of ParamConverter.
Constructor Details
#initialize(shape) ⇒ ParamConverter
Returns a new instance of ParamConverter.
15 16 17 |
# File '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 }
98 99 100 |
# File '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 |
.c(shape, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 106 107 108 109 |
# File 'lib/seahorse/client/param_converter.rb', line 103 def c(shape, value) if converter = converter_for(shape, value) converter.call(value) else value end end |
.convert(shape, params) ⇒ Hash
79 80 81 |
# File 'lib/seahorse/client/param_converter.rb', line 79 def convert(shape, params) new(shape).convert(params) end |
Instance Method Details
#convert(params) ⇒ Hash
21 22 23 |
# File 'lib/seahorse/client/param_converter.rb', line 21 def convert(params) structure(@shape, params) end |