Sha256: 28154c91a8c7851e8c7a559a245b596771c1576cc8c6883067ec423b37905f9c

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

module NxtSchema
  module Node
    class MaybeEvaluator
      def initialize(value:)
        @value = value
      end

      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

      def evaluator(target, *args)
        Callable.new(value, target, *args)
      end

      attr_reader :value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nxt_schema-1.0.0 lib/nxt_schema/node/maybe_evaluator.rb