Sha256: 8c865bb1142014bde48f4d0c4662cddea0220bddcea433968eda96ec80b814ee

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require "dry/validation/constants"

module Dry
  module Validation
    # A wrapper for macro validation blocks
    #
    # @api public
    class Macro < Function
      # @!attribute [r] name
      #   @return [Symbol]
      #   @api public
      param :name

      # @!attribute [r] args
      #   @return [Array]
      #   @api public
      option :args

      # @!attribute [r] block
      #   @return [Proc]
      #   @api private
      option :block

      # @api private
      def with(args)
        self.class.new(name, args: args, block: block)
      end

      # @api private
      def extract_block_options(options)
        block_options.transform_values { options[_1] }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-validation-1.11.1 lib/dry/validation/macro.rb
dry-validation-1.11.0 lib/dry/validation/macro.rb
dry-validation-1.10.0 lib/dry/validation/macro.rb
dry-validation-1.9.0 lib/dry/validation/macro.rb