Class: NxtSchema::Template::MaybeEvaluator
- Inherits:
-
Object
- Object
- NxtSchema::Template::MaybeEvaluator
- Defined in:
- lib/nxt_schema/template/maybe_evaluator.rb
Instance Method Summary collapse
- #call(target = nil, *args) ⇒ Object
-
#initialize(value:) ⇒ MaybeEvaluator
constructor
A new instance of MaybeEvaluator.
Constructor Details
#initialize(value:) ⇒ MaybeEvaluator
Returns a new instance of MaybeEvaluator.
4 5 6 |
# File 'lib/nxt_schema/template/maybe_evaluator.rb', line 4 def initialize(value:) @value = value end |
Instance Method Details
#call(target = nil, *args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nxt_schema/template/maybe_evaluator.rb', line 8 def call(target = nil, *args) evaluator = evaluator(target, *args) if evaluator.value? # When a value was given we check if this equals to the input evaluator.call == target else evaluator.call end end |