Sha256: 7f01c1f63fedb04f7ad24139090b9e0132a47cb76d388a5c70b2d494caa9da8d
Contents?: true
Size: 662 Bytes
Versions: 11
Compression:
Stored size: 662 Bytes
Contents
module Betterdocs::Dsl::JsonTypeMapper module_function def derive_json_type_from(klass) Class === klass or klass = klass.class { TrueClass => 'boolean', FalseClass => 'boolean', NilClass => 'null', Numeric => 'number', Array => 'array', Hash => 'object', String => 'string', }.find { |match_class, json_type| match_class >= klass and break json_type } || 'undefined' end def map_types(types) if Array === types and types.empty? types = [ types ] else types = Array(types) end types.map { |t| derive_json_type_from(t) }.uniq.sort end end
Version data entries
11 entries across 11 versions & 1 rubygems