class Aws::Templates::Utils::Parametrized::Constraint::AllOf

Aggregate constraint

It is used to perform checks against a list of constraints-functors or lambdas.

Example

class Piece
  include Aws::Templates::Utils::Parametrized
  parameter :param1,
    :constraint => all_of(
      not_nil,
      satisfies("Should be moderate") { |v| v < 100 }
    )
end

i = Piece.new(:param1 => nil)
i.param1 # raise ParameterValueInvalid
i = Piece.new(:param1 => 200)
i.param1 # raise ParameterValueInvalid with description
i = Piece.new(:param1 => 50)
i.param1 # => 50

Attributes

constraints[R]

Public Class Methods

new(constraints) click to toggle source
# File lib/aws/templates/utils/parametrized/constraint/all_of.rb, line 34
def initialize(constraints)
  @constraints = constraints
  self.if(Parametrized.any)
end

Protected Instance Methods

check(parameter, value, instance) click to toggle source
# File lib/aws/templates/utils/parametrized/constraint/all_of.rb, line 41
def check(parameter, value, instance)
  constraints.each do |c|
    instance.instance_exec(parameter, value, &c)
  end
end