Class: Aws::ParamConverter Private
- Inherits:
- 
      Object
      
        - Object
- Aws::ParamConverter
 
- Includes:
- Seahorse::Model::Shapes
- Defined in:
- lib/aws-sdk-core/param_converter.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #opened_files ⇒ Object readonly private
Class Method Summary collapse
- 
  
    
      .add(shape_class, value_class, converter = nil, &block)  ⇒ void 
    
    
  
  
  
  
  
  
  
  private
  
    Registers a new value converter. 
- .c(shape, value, instance = nil) ⇒ Object private
- .convert(shape, params) ⇒ Object private
- .ensure_open(file, converter) ⇒ Object private
Instance Method Summary collapse
- #close_opened_files ⇒ Object private
- #convert(params) ⇒ Hash private
- 
  
    
      #initialize(rules)  ⇒ ParamConverter 
    
    
  
  
  
    constructor
  
  
  
  
  
  private
  
    A new instance of ParamConverter. 
Constructor Details
#initialize(rules) ⇒ ParamConverter
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.
Returns a new instance of ParamConverter.
| 18 19 20 21 | # File 'lib/aws-sdk-core/param_converter.rb', line 18 def initialize(rules) @rules = rules @opened_files = [] end | 
Instance Attribute Details
#opened_files ⇒ Object (readonly)
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.
| 24 25 26 | # File 'lib/aws-sdk-core/param_converter.rb', line 24 def opened_files @opened_files end | 
Class Method Details
.add(shape_class, value_class, converter = nil, &block) ⇒ void
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.
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 }
| 111 112 113 | # File 'lib/aws-sdk-core/param_converter.rb', line 111 def add(shape_class, value_class, converter = nil, &block) @converters[shape_class][value_class] = converter || block end | 
.c(shape, value, instance = nil) ⇒ 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.
| 126 127 128 129 130 131 132 | # File 'lib/aws-sdk-core/param_converter.rb', line 126 def c(shape, value, instance = nil) if converter = converter_for(shape, value) converter.call(value, instance) else value end end | 
.convert(shape, params) ⇒ 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.
| 92 93 94 | # File 'lib/aws-sdk-core/param_converter.rb', line 92 def convert(shape, params) new(shape).convert(params) end | 
.ensure_open(file, converter) ⇒ 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.
| 115 116 117 118 119 120 121 122 123 | # File 'lib/aws-sdk-core/param_converter.rb', line 115 def ensure_open(file, converter) if file.closed? new_file = File.open(file.path, 'rb') converter.opened_files << new_file new_file else file end end | 
Instance Method Details
#close_opened_files ⇒ 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.
| 36 37 38 39 | # File 'lib/aws-sdk-core/param_converter.rb', line 36 def close_opened_files @opened_files.each(&:close) @opened_files = [] end | 
#convert(params) ⇒ Hash
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.
| 28 29 30 31 32 33 34 | # File 'lib/aws-sdk-core/param_converter.rb', line 28 def convert(params) if @rules structure(@rules, params) else params end end |