class Stannum::Constraints::Boolean
A Boolean
constraint matches only true or false.
@example Using a Boolean
constraint
constraint = Stannum::Constraints::Boolean.new constraint.matches?(nil) #=> false constraint.matches?('a string') #=> false constraint.matches?(false) #=> true constraint.matches?(true) #=> true
Constants
- NEGATED_TYPE
The :type of the error generated for a matching object.
- TYPE
The :type of the error generated for a non-matching object.
Public Instance Methods
matches?(actual)
click to toggle source
Checks that the object is either true or false.
@return [true, false] true if the object is true or false, otherwise
false.
@see Stannum::Constraint#matches?
# File lib/stannum/constraints/boolean.rb, line 28 def matches?(actual) true.equal?(actual) || false.equal?(actual) end
Also aliased as: match?