mirror of
https://github.com/ditkrg/schemable.git
synced 2026-01-22 22:26:41 +00:00
Uses configs to check whether to use string or number for decimal and float types
This commit is contained in:
parent
9f6ecb935d
commit
cddc117b47
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user