Uses configs to check whether to use string or number for decimal and float types

This commit is contained in:
Muhammad Nawzad 2023-09-26 14:15:16 +03:00
parent 9f6ecb935d
commit cddc117b47
No known key found for this signature in database
GPG Key ID: B954B6AAE33940B2

View File

@ -19,8 +19,8 @@ module Schemable
text: { type: :string },
string: { type: :string },
integer: { type: :integer },
float: { type: :number, format: :float },
decimal: { type: :number, format: :double },
float: { type: (configs[:float_as_string] ? :string : :number).to_s.to_sym, format: :float },
decimal: { type: (configs[:decimal_as_string] ? :string : :number).to_s.to_sym, format: :double },
datetime: { type: :string, format: :'date-time' },
date: { type: :string, format: :date },
time: { type: :string, format: :time },
@ -932,5 +932,15 @@ module Schemable
def camelize_keys(hash)
hash.deep_transform_keys { |key| key.to_s.camelize(:lower).to_sym }
end
# Returns a json of config options for the definition class.
#
# @return [Hash] The config options for the definition class.
#
# @example
# { decimal_as_string: true }
def configs
{}
end
end
end