Sha256: 792c573b5ccf4065147ff9f41643b78ca83d856dee77e6e783916e248c80d899

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

module NxtSchema
  module Node
    class MaybeEvaluator
      def initialize(node, evaluator, value)
        @node = node
        @evaluator = evaluator
        @value = value
      end

      attr_reader :node, :evaluator, :value

      def call
        if evaluator.respond_to?(:call)
          Callable.new(evaluator).call(node, value)
        elsif value.is_a?(Symbol) && value.respond_to?(evaluator)
          Callable.new(evaluator).bind(value).call(node, value)
        else
          value == evaluator
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nxt_schema-0.1.2 lib/nxt_schema/node/maybe_evaluator.rb
nxt_schema-0.1.1 lib/nxt_schema/node/maybe_evaluator.rb
nxt_schema-0.1.0 lib/nxt_schema/node/maybe_evaluator.rb