Sha256: d7849ba92fef580672adf5a1b2c6e11e2e783daa47767abd095bfce81010635d

Contents?: true

Size: 679 Bytes

Versions: 12

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

require "dry-types"

module Pakyow
  module Types
    include Dry.Types(default: :nominal)

    MAPPING = {
      string: Coercible::String,
      boolean: Params::Bool,
      date: Params::Date,
      time: Params::Time,
      datetime: Params::Time,
      integer: Params::Integer,
      float: Params::Float,
      decimal: Params::Decimal
    }.freeze

    def self.type_for(type)
      if type.is_a?(Dry::Types::Type)
        type
      else
        MAPPING.fetch(type.to_sym)
      end
    rescue KeyError => error
      raise UnknownType.build(error, type: type, context: {
        type: type, types: MAPPING.keys
      })
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pakyow-core-1.0.6 lib/pakyow/types.rb
pakyow-core-1.0.5 lib/pakyow/types.rb
pakyow-core-1.0.4 lib/pakyow/types.rb
pakyow-core-1.0.3 lib/pakyow/types.rb
pakyow-core-1.0.2 lib/pakyow/types.rb
pakyow-core-1.0.1 lib/pakyow/types.rb
pakyow-core-1.0.0 lib/pakyow/types.rb
pakyow-core-1.0.0.rc5 lib/pakyow/types.rb
pakyow-core-1.0.0.rc4 lib/pakyow/types.rb
pakyow-core-1.0.0.rc3 lib/pakyow/types.rb
pakyow-core-1.0.0.rc2 lib/pakyow/types.rb
pakyow-core-1.0.0.rc1 lib/pakyow/types.rb