Sha256: c2319b369751f07cee9061fe37047d570ca330f30ccc63f3d08bc9d54b984712

Contents?: true

Size: 572 Bytes

Versions: 2

Compression:

Stored size: 572 Bytes

Contents

# frozen_string_literal: true

require 'singleton'

module Kind
  class Checker
    class Factory
      include Singleton

      def self.create(kind)
        instance.create(kind)
      end

      def initialize
        @__checkers__ = {}
      end

      def create(kind)
        @__checkers__[kind] ||= begin
          kind_name = kind.name

          if Kind::Of.const_defined?(kind_name, false)
            Kind::Of.const_get(kind_name)
          else
            Kind::Checker.new(Kind.of_module_or_class(kind))
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kind-4.1.0 lib/kind/deprecations/checker/factory.rb
kind-4.0.0 lib/kind/deprecations/checker/factory.rb