Sha256: ecff24bc48b543d9ac05c6867d74c6de5001c501290f1daefc787c5bab952660

Contents?: true

Size: 537 Bytes

Versions: 2

Compression:

Stored size: 537 Bytes

Contents

module NxtSchema
  module Template
    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

2 entries across 2 versions & 1 rubygems

Version Path
nxt_schema-1.0.2 lib/nxt_schema/template/on_evaluator.rb
nxt_schema-1.0.1 lib/nxt_schema/template/on_evaluator.rb