Class: Exa::Services::ParameterConverter
- Inherits:
-
Object
- Object
- Exa::Services::ParameterConverter
- Defined in:
- lib/exa/services/parameter_converter.rb
Overview
Converts Ruby parameter names (snake_case) to API format (camelCase) Handles both simple parameters and nested content parameters
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.convert(params) ⇒ Object
8 9 10 |
# File 'lib/exa/services/parameter_converter.rb', line 8 def self.convert(params) new.convert(params) end |
Instance Method Details
#convert(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/exa/services/parameter_converter.rb', line 12 def convert(params) converted = {} contents = {} params.each do |key, value| if content_key?(key) contents[convert_content_key(key)] = convert_content_value(key, value) else converted[convert_key(key)] = value end end converted[:contents] = contents if contents.any? converted end |