Sha256: 2ee851415e82fda925dce2633c298575014c33edf6e7e4cb100ba625273ded75

Contents?: true

Size: 533 Bytes

Versions: 1

Compression:

Stored size: 533 Bytes

Contents

module NxtSchema
  module Node
    class OnEvaluator
      def initialize(condition:, value:)
        @condition = condition
        @value = value
      end

      def call(target = nil, *args, &block)
        return unless condition_applies?(target, *args)

        result = Callable.new(value, target, *args).call
        block.yield(result)
      end

      private

      def condition_applies?(target, *args)
        Callable.new(condition, target, *args).call
      end

      attr_reader :condition, :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/on_evaluator.rb