Class: Validate::AST::Rules::Unanimous
Instance Method Summary
collapse
included
Methods included from Combinator
#respond_to_missing?
Methods inherited from Constraint
#==, create_class, inherited, #method_missing, #respond_to_missing?, #to_s
Constructor Details
#initialize(constraints) ⇒ Unanimous
Returns a new instance of Unanimous.
266
267
268
|
# File 'lib/validate/ast.rb', line 266
def initialize(constraints)
@constraints = constraints.freeze
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Validate::Constraint
Instance Method Details
#inspect ⇒ Object
281
282
283
284
285
|
# File 'lib/validate/ast.rb', line 281
def inspect
return @constraints.first.inspect if @constraints.one?
"(#{@constraints.map(&:inspect).join(' & ')})"
end
|
#message ⇒ Object
287
288
289
290
291
292
293
|
# File 'lib/validate/ast.rb', line 287
def message
'both ' + @constraints
.size
.times
.map { |i| "[#{constraint_message(i)}]" }
.join(', and ')
end
|
#name ⇒ Object
277
278
279
|
# File 'lib/validate/ast.rb', line 277
def name
'both_' + @constraints.map(&:name).sort.join('_and_')
end
|
#valid?(value, _ = Constraints::ValidationContext.none) ⇒ Boolean