Class: InferModel::ValueTypeGuesser
- Inherits:
-
Object
- Object
- InferModel::ValueTypeGuesser
- Extended by:
- Dry::Initializer, Callable
- Defined in:
- lib/infer_model/value_type_guesser.rb
Constant Summary collapse
- INTEGER_RESULT =
bigint included
:integer
- DECIMAL_RESULT =
float included
:decimal
- DATETIME_RESULT =
date included
:datetime
- TIME_RESULT =
:time
- BOOLEAN_RESULT =
:boolean
- JSON_RESULT =
:json
- UUID_RESULT =
:uuid
- STRING_RESULT =
text included
:string
- RESULT_TYPES =
ordered by specifity (string should come last, integer before decimal etc.)
[ # ordered by specifity (string should come last, integer before decimal etc.) INTEGER_RESULT, DECIMAL_RESULT, BOOLEAN_RESULT, TIME_RESULT, DATETIME_RESULT, JSON_RESULT, UUID_RESULT, STRING_RESULT, ].freeze
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/infer_model/value_type_guesser.rb', line 32 def call raise Error, "Provide strings only for guessing the type" unless input.is_a?(String) || input.nil? if multi ordered_available_known_types.filter { |type| may_be?(type) } else ordered_available_known_types.find { |type| may_be?(type) } end end |