class NxtSchema::Template::MaybeEvaluator

Attributes

value[R]

Public Class Methods

new(value:) click to toggle source
# File lib/nxt_schema/template/maybe_evaluator.rb, line 4
def initialize(value:)
  @value = value
end

Public Instance Methods

call(target = nil, *args) click to toggle source
# 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

Private Instance Methods

evaluator(target, *args) click to toggle source
# File lib/nxt_schema/template/maybe_evaluator.rb, line 21
def evaluator(target, *args)
  Callable.new(value, target, *args)
end