Sha256: 36b023d9da604bd295ae4ef3b69c4ec377e36cf46f2c54d625ce67f2b02b7303

Contents?: true

Size: 885 Bytes

Versions: 7

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

require "dry/types/coercions/json"

module Dry
  module Types
    register("json.nil") do
      self["nominal.nil"].constructor(Coercions::JSON.method(:to_nil))
    end

    register("json.date") do
      self["nominal.date"].constructor(Coercions::JSON.method(:to_date))
    end

    register("json.date_time") do
      self["nominal.date_time"].constructor(Coercions::JSON.method(:to_date_time))
    end

    register("json.time") do
      self["nominal.time"].constructor(Coercions::JSON.method(:to_time))
    end

    register("json.decimal") do
      self["nominal.decimal"].constructor(Coercions::JSON.method(:to_decimal))
    end

    register("json.symbol") do
      self["nominal.symbol"].constructor(Coercions::JSON.method(:to_symbol))
    end

    register("json.array") { self["array"] }

    register("json.hash") { self["hash"] }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-types-1.7.2 lib/dry/types/json.rb
dry-types-1.7.1 lib/dry/types/json.rb
dry-types-1.7.0 lib/dry/types/json.rb
dry-types-1.6.1 lib/dry/types/json.rb
dry-types-1.6.0 lib/dry/types/json.rb
dry-types-1.5.1 lib/dry/types/json.rb
dry-types-1.5.0 lib/dry/types/json.rb