mirror of
https://github.com/ditkrg/schemable.git
synced 2026-01-23 06:36:40 +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 },
|
text: { type: :string },
|
||||||
string: { type: :string },
|
string: { type: :string },
|
||||||
integer: { type: :integer },
|
integer: { type: :integer },
|
||||||
float: { type: :number, format: :float },
|
float: { type: (configs[:float_as_string] ? :string : :number).to_s.to_sym, format: :float },
|
||||||
decimal: { type: :number, format: :double },
|
decimal: { type: (configs[:decimal_as_string] ? :string : :number).to_s.to_sym, format: :double },
|
||||||
datetime: { type: :string, format: :'date-time' },
|
datetime: { type: :string, format: :'date-time' },
|
||||||
date: { type: :string, format: :date },
|
date: { type: :string, format: :date },
|
||||||
time: { type: :string, format: :time },
|
time: { type: :string, format: :time },
|
||||||
@ -932,5 +932,15 @@ module Schemable
|
|||||||
def camelize_keys(hash)
|
def camelize_keys(hash)
|
||||||
hash.deep_transform_keys { |key| key.to_s.camelize(:lower).to_sym }
|
hash.deep_transform_keys { |key| key.to_s.camelize(:lower).to_sym }
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user