Module: Dry::Validation::Macros

Defined in:
lib/dry/validation/macros.rb

Overview

API for registering and accessing Rule macros

Defined Under Namespace

Modules: Registrar Classes: Container

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Proc

Return a registered macro

Parameters:

  • name (Symbol)

    The name of the macro

Returns:

  • (Proc)


72
73
74
# File 'lib/dry/validation/macros.rb', line 72

def self.[](name)
  container[name]
end

.containerObject

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.



89
90
91
# File 'lib/dry/validation/macros.rb', line 89

def self.container
  @container ||= Container.new
end

.register(name, *args, &block) ⇒ Macros

Register a global macro



83
84
85
86
# File 'lib/dry/validation/macros.rb', line 83

def self.register(name, *args, &block)
  container.register(name, *args, &block)
  self
end