Sha256: cfa9ffe7b76704418686af90b94d91d7f7aa9b794114d0b6a13f7013fb38d3d1

Contents?: true

Size: 788 Bytes

Versions: 9

Compression:

Stored size: 788 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.map { |key, value| [key, options[value]] }.to_h
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dry-validation-1.7.0 lib/dry/validation/macro.rb
dry-validation-1.6.0 lib/dry/validation/macro.rb
dry-validation-1.5.6 lib/dry/validation/macro.rb
dry-validation-1.5.5 lib/dry/validation/macro.rb
dry-validation-1.5.4 lib/dry/validation/macro.rb
dry-validation-1.5.3 lib/dry/validation/macro.rb
dry-validation-1.5.2 lib/dry/validation/macro.rb
dry-validation-1.5.1 lib/dry/validation/macro.rb
dry-validation-1.5.0 lib/dry/validation/macro.rb