Class: Dry::Validation::Macro

Inherits:
Function
  • Object
show all
Defined in:
lib/dry/validation/macro.rb

Overview

A wrapper for macro validation blocks

Instance Attribute Summary collapse

Attributes inherited from Function

#block_options

Instance Method Summary collapse

Instance Attribute Details

#argsArray (readonly)

Returns:

  • (Array)

20
# File 'lib/dry/validation/macro.rb', line 20

option :args

#blockProc (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)

25
# File 'lib/dry/validation/macro.rb', line 25

option :block

#nameSymbol (readonly)

Returns:

  • (Symbol)

15
# File 'lib/dry/validation/macro.rb', line 15

param :name

Instance Method Details

#extract_block_options(options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


33
34
35
# File 'lib/dry/validation/macro.rb', line 33

def extract_block_options(options)
  block_options.map { |key, value| [key, options[value]] }.to_h
end

#with(args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


28
29
30
# File 'lib/dry/validation/macro.rb', line 28

def with(args)
  self.class.new(name, args: args, block: block)
end