module FastAPI::Conversions
Public Class Methods
convert_type(val, type, field = nil)
click to toggle source
# File lib/fastapi/conversions.rb, line 4 def self.convert_type(val, type, field = nil) if val && is_array(field) Oj.load(val).map { |inner_value| convert_value(inner_value, type) } else convert_value(val, type) end end
Private Class Methods
convert_value(val, type)
click to toggle source
# File lib/fastapi/conversions.rb, line 17 def self.convert_value(val, type) if val case type when :integer val.to_i when :float val.to_f when :boolean { 't' => true, 'f' => false }[val] else val end end end
is_array(field)
click to toggle source
# File lib/fastapi/conversions.rb, line 13 def self.is_array(field) field && field.respond_to?('array') && field.array end