Class: Aws::Templates::Utils::Parametrized::Constraint::SatisfiesCondition

Inherits:
Aws::Templates::Utils::Parametrized::Constraint show all
Defined in:
lib/aws/templates/utils/parametrized/constraints.rb

Overview

Check if value satisfies the condition

Checks if value satisfies the condition defined in the block which should return true if the condition is met and false if it’s not. If value fails the check, an exception will be thrown with attached condition description. The description is a part of constraint definition.

The block is evaluated in the functor’s invocation context.

Example

class Piece
  include Aws::Templates::Utils::Parametrized
  parameter :param1,
    :constraint => satisfies('Mediocre value') { |v| v < 100 }
end

i = Piece.new(:param2 => 1)
i.param1 # => 1
i = Piece.new(:param1 => 101)
i.param1 # raise ParameterValueInvalid

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Aws::Templates::Utils::Parametrized::Constraint

#check_wrapper, #to_proc

Constructor Details

#initialize(description, &cond_block) ⇒ SatisfiesCondition

Returns a new instance of SatisfiesCondition.



220
221
222
223
# File 'lib/aws/templates/utils/parametrized/constraints.rb', line 220

def initialize(description, &cond_block)
  @condition = cond_block
  @description = description
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



217
218
219
# File 'lib/aws/templates/utils/parametrized/constraints.rb', line 217

def condition
  @condition
end

#descriptionObject (readonly)

Returns the value of attribute description.



218
219
220
# File 'lib/aws/templates/utils/parametrized/constraints.rb', line 218

def description
  @description
end