Sha256: 189e754659c8b7a9398c96177335b9945151a711beaa96a85d6e4688177d786c

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

require 'dry/data/coercions/form'

module Dry
  module Data
    register('form.nil') do
      Type.new(Coercions::Form.method(:to_nil), NilClass)
    end

    register('form.date') do
      Type.new(Coercions::Form.method(:to_date), Date)
    end

    register('form.date_time') do
      Type.new(Coercions::Form.method(:to_date_time), DateTime)
    end

    register('form.time') do
      Type.new(Coercions::Form.method(:to_time), Time)
    end

    register('form.true') do
      Type.new(Coercions::Form.method(:to_true), TrueClass)
    end

    register('form.false') do
      Type.new(Coercions::Form.method(:to_false), FalseClass)
    end

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

    register('form.int') do
      Type.new(Coercions::Form.method(:to_int), Fixnum)
    end

    register('form.float') do
      Type.new(Coercions::Form.method(:to_float), Float)
    end

    register('form.decimal') do
      Type.new(Coercions::Form.method(:to_decimal), BigDecimal)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-data-0.4.2 lib/dry/data/types/form.rb
dry-data-0.4.1 lib/dry/data/types/form.rb
dry-data-0.4.0 lib/dry/data/types/form.rb
dry-data-0.3.2 lib/dry/data/types/form.rb
dry-data-0.3.1 lib/dry/data/types/form.rb
dry-data-0.3.0 lib/dry/data/types/form.rb
dry-data-0.2.1 lib/dry/data/types/form.rb