Module: Expectant::Types
- Defined in:
- lib/expectant/types.rb
Class Method Summary collapse
Class Method Details
.resolve(type_definition) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/expectant/types.rb', line 9 def self.resolve(type_definition) case type_definition when nil Any when Symbol resolve_symbol(type_definition) when Dry::Types::Type # Already a dry-type, return as-is type_definition when Class Instance(type_definition) else raise ConfigurationError, "Invalid type definition: #{type_definition}" end end |
.resolve_symbol(symbol) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/expectant/types.rb', line 25 def self.resolve_symbol(symbol) case symbol when :string, :str Params::String when :integer, :int Params::Integer when :float Params::Float when :decimal Params::Decimal when :boolean, :bool Params::Bool when :date Params::Date when :datetime Params::DateTime when :time Params::Time when :array Params::Array when :hash Params::Hash when :symbol, :sym Symbol when :any, :nil Any else raise ConfigurationError, "Unknown type symbol: #{symbol}" end end |