class ClassyHash::Generate::Composite
Used by the .all and .not generators. Do not use directly.
Attributes
constraints[R]
Array of constraints to apply together.
negate[R]
True if the constraints must all not match, false if they must all match.
Public Class Methods
new(constraints, negate = false)
click to toggle source
Initializes a composite constraint with the given Array of constraints
. If negate
is true, then the constraints must all fail for the value to pass.
# File lib/classy_hash/generate.rb, line 21 def initialize(constraints, negate = false) raise 'No constraints were given' if constraints.empty? @constraints = constraints @negate = negate end
Public Instance Methods
describe(value)
click to toggle source
Returns a String describing the composite constraint failing against the given value
.
# File lib/classy_hash/generate.rb, line 30 def describe(value) "#{negate ? 'none' : 'all'} of [#{CH.constraint_string(constraints, value)}]" end