File: json.rb

package info (click to toggle)
ruby-dry-types 1.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 504 kB
  • sloc: ruby: 3,059; makefile: 4
file content (35 lines) | stat: -rw-r--r-- 885 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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