Module: Validate::Constraints
- Includes:
- Arguments
- Defined in:
- lib/validate/constraints.rb,
lib/validate/constraints/validation_context.rb
Defined Under Namespace
Classes: ValidationContext
Class Method Summary collapse
Methods included from Arguments
Class Method Details
.define(name, **defaults, &body) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/validate/constraints.rb', line 16 def self.define(name, **defaults, &body) if @reserved_names.include?(name) raise Error::ArgumentError, "#{name} is already defined" end @reserved_names[name] = name constraint_class = Constraint.create_class(name, **defaults, &body) Constraints.const_set(Helpers.camelize(name), constraint_class) define_method(name, &constraint_class.method(:new)) module_function(name) end |