Class: Aws::Templates::Utils::Parametrized::Constraint::SatisfiesCondition
- Inherits:
-
Aws::Templates::Utils::Parametrized::Constraint
- Object
- Aws::Templates::Utils::Parametrized::Constraint
- Aws::Templates::Utils::Parametrized::Constraint::SatisfiesCondition
- Defined in:
- lib/aws/templates/utils/parametrized/constraint/satisfies_condition.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
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
-
#initialize(description, &cond_block) ⇒ SatisfiesCondition
constructor
A new instance of SatisfiesCondition.
Methods inherited from Aws::Templates::Utils::Parametrized::Constraint
#check_wrapper, #if, #pre_condition, #to_proc
Constructor Details
#initialize(description, &cond_block) ⇒ SatisfiesCondition
Returns a new instance of SatisfiesCondition.
35 36 37 38 |
# File 'lib/aws/templates/utils/parametrized/constraint/satisfies_condition.rb', line 35 def initialize(description, &cond_block) @condition = cond_block @description = description end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
32 33 34 |
# File 'lib/aws/templates/utils/parametrized/constraint/satisfies_condition.rb', line 32 def condition @condition end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
33 34 35 |
# File 'lib/aws/templates/utils/parametrized/constraint/satisfies_condition.rb', line 33 def description @description end |