Sha256: 192ecf4692d973282d689c1da6c8b37f6837ea4ed50e41c472ac907b39cdfa2c

Contents?: true

Size: 671 Bytes

Versions: 4

Compression:

Stored size: 671 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

      MODULE_OR_CLASS = 'Module/Class'.freeze

      private_constant :MODULE_OR_CLASS

      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, kind, MODULE_OR_CLASS))
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kind-3.1.0 lib/kind/checker/factory.rb
kind-3.0.1 lib/kind/checker/factory.rb
kind-3.0.0 lib/kind/checker/factory.rb
kind-2.3.0 lib/kind/checker/factory.rb