Module: Pakyow::Data::Types
- Defined in:
- lib/pakyow/data/types.rb
Constant Summary collapse
- MAPPING =
{ boolean: Bool.(mapping: :boolean), date: Date.(mapping: :date), datetime: DateTime.(mapping: :datetime), decimal: Coercible::Decimal.(mapping: :decimal), float: Coercible::Float.(mapping: :float), integer: Coercible::Integer.(mapping: :integer), string: Coercible::String.(mapping: :string), time: Time.(mapping: :time) }.freeze
Class Method Summary collapse
Class Method Details
.type_for(type, additional_types = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pakyow/data/types.rb', line 21 def self.type_for(type, additional_types = {}) if type.is_a?(Dry::Types::Type) type else type = type.to_sym additional_types.to_h.fetch(type) { MAPPING.fetch(type) } end rescue KeyError => error raise UnknownType.build(error, type: type, context: { type: type, types: MAPPING.keys }) end |