Sha256: 86fc19551517db39059073681b12458ac7e6df1a48e0e4c5df9855ec7fae69a2

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

module Dry
  module Types
    module Options
      # @return [Hash]
      attr_reader :options

      # @see Definition#initialize
      def initialize(*args, meta: EMPTY_HASH, **options)
        @__args__ = args
        @options = options
        @meta = meta
      end

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

      # @overload meta
      #   @return [Hash] metadata associated with type
      #
      # @overload meta(data)
      #   @param [Hash] new metadata to merge into existing metadata
      #   @return [Type] new type with added metadata
      def meta(data = nil)
        data ? with(meta: @meta.merge(data)) : @meta
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-types-0.10.0 lib/dry/types/options.rb