Sha256: 8d329395b286922d35e4f222db2a434fcf6a6869ebba1491aaa3c9af6eb8711a

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

require 'dry/types/coercions/params'

module Dry
  module Types
    register('params.nil') do
      self['nil'].constructor(Coercions::Params.method(:to_nil))
    end

    register('params.date') do
      self['date'].constructor(Coercions::Params.method(:to_date))
    end

    register('params.date_time') do
      self['date_time'].constructor(Coercions::Params.method(:to_date_time))
    end

    register('params.time') do
      self['time'].constructor(Coercions::Params.method(:to_time))
    end

    register('params.true') do
      self['true'].constructor(Coercions::Params.method(:to_true))
    end

    register('params.false') do
      self['false'].constructor(Coercions::Params.method(:to_false))
    end

    register('params.bool') do
      (self['params.true'] | self['params.false']).safe
    end

    register('params.integer') do
      self['integer'].constructor(Coercions::Params.method(:to_int))
    end

    register('params.float') do
      self['float'].constructor(Coercions::Params.method(:to_float))
    end

    register('params.decimal') do
      self['decimal'].constructor(Coercions::Params.method(:to_decimal))
    end

    register('params.array') do
      self['array'].constructor(Coercions::Params.method(:to_ary)).safe
    end

    register('params.hash') do
      self['hash'].constructor(Coercions::Params.method(:to_hash)).safe
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-types-0.14.1 lib/dry/types/params.rb
dry-types-0.14.0 lib/dry/types/params.rb
dry-types-0.13.4 lib/dry/types/params.rb
dry-types-0.13.3 lib/dry/types/params.rb
dry-types-0.13.2 lib/dry/types/params.rb
dry-types-0.13.1 lib/dry/types/params.rb
dry-types-0.13.0 lib/dry/types/params.rb