Sha256: 3391f7cb354fe99b469aeb1e75b828cdf55c83f46ad5685ca199ce8c2f88c931

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module Dry
  module Types
    # A registry with predicate objects from `Dry::Logic::Predicates`
    #
    # @api private
    class PredicateRegistry
      # @api private
      attr_reader :predicates

      # @api private
      attr_reader :has_predicate

      KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
      private_constant(:KERNEL_RESPOND_TO)

      # @api private
      def initialize(predicates = Logic::Predicates)
        @predicates = predicates
      end

      # @api private
      def key?(name)
        KERNEL_RESPOND_TO.bind_call(@predicates, name)
      end

      # @api private
      def [](name) = predicates[name]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-types-1.8.1 lib/dry/types/predicate_registry.rb
dry-types-1.8.0 lib/dry/types/predicate_registry.rb