Sha256: f247eaf92f318526405f77eea8b2b4546af9dd6a2d31d80bbc0b2bfc65eb2fd3

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

require "dry/validation/constants"
require "dry/validation/function"

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

2 entries across 2 versions & 1 rubygems

Version Path
dry-validation-1.8.1 lib/dry/validation/macro.rb
dry-validation-1.8.0 lib/dry/validation/macro.rb