Class: Aws::Templates::Utils::Parametrized::Constraint::Requires
- Inherits:
-
Aws::Templates::Utils::Parametrized::Constraint
- Object
- Aws::Templates::Utils::Parametrized::Constraint
- Aws::Templates::Utils::Parametrized::Constraint::Requires
- Defined in:
- lib/aws/templates/utils/parametrized/constraint/requires.rb
Overview
Check presence of parameters if the condition is met
Requires presence of the methods passed as dependencies in the current scope with non-nil returning values. Default condition for the value is not to be nil. The condition can be either a block or a value.
Example
class Piece
include Aws::Templates::Utils::Parametrized
parameter :param2
parameter :param1, :constraint => requires(:param2)
end
i = Piece.new(:param2 => 1)
i.param1 # => nil
i = Piece.new(:param1 => 1)
i.param1 # raise ParameterValueInvalid
i = Piece.new(:param1 => 2, :param2 => 1)
i.param1 # => 2
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
-
#initialize(dependencies) ⇒ Requires
constructor
A new instance of Requires.
Methods inherited from Aws::Templates::Utils::Parametrized::Constraint
#check_wrapper, #if, #pre_condition, #to_proc
Constructor Details
#initialize(dependencies) ⇒ Requires
Returns a new instance of Requires.
33 34 35 |
# File 'lib/aws/templates/utils/parametrized/constraint/requires.rb', line 33 def initialize(dependencies) @dependencies = dependencies end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
31 32 33 |
# File 'lib/aws/templates/utils/parametrized/constraint/requires.rb', line 31 def dependencies @dependencies end |