Sha256: 50c0f91a368d98c2a4d67a7e6ac0ceb812d1d9a6b3f582f9901eba5da05e59d9

Contents?: true

Size: 694 Bytes

Versions: 7

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

require 'dry/logic/predicates'

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

      # @api private
      def initialize(predicates = Logic::Predicates)
        @predicates = predicates
        @has_predicate = ::Kernel.instance_method(:respond_to?).bind(@predicates)
      end

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

      # @api private
      def key?(name)
        has_predicate.(name)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/dry-types-1.4.0/lib/dry/types/predicate_registry.rb
dry-types-1.4.0 lib/dry/types/predicate_registry.rb
dry-types-1.3.1 lib/dry/types/predicate_registry.rb
dry-types-1.3.0 lib/dry/types/predicate_registry.rb
dry-types-1.2.2 lib/dry/types/predicate_registry.rb
dry-types-1.2.1 lib/dry/types/predicate_registry.rb
dry-types-1.2.0 lib/dry/types/predicate_registry.rb