File: options.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 (30 lines) | stat: -rw-r--r-- 582 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
# frozen_string_literal: true

module Dry
  module Types
    # Common API for types with options
    #
    # @api private
    module Options
      # @return [Hash]
      attr_reader :options

      # @see Nominal#initialize
      #
      # @api private
      def initialize(*args, **options)
        @__args__ = args.freeze
        @options = options.freeze
      end

      # @param [Hash] new_options
      #
      # @return [Type]
      #
      # @api private
      def with(**new_options)
        self.class.new(*@__args__, **options, **new_options)
      end
    end
  end
end