Sha256: 6b7606697536c75e7e97cec9e102afd9adcce6b5d4c27207f5ac7ed310b02c4b

Contents?: true

Size: 678 Bytes

Versions: 12

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

module Remocon
  class TypeNormalizerFactory
    include Singleton

    def self.register(normalizer_klass)
      raise "#{normalizer_klass} must inherit #{Remocon::Normalizer}" unless normalizer_klass < Remocon::Normalizer
      instance.plugin_map[normalizer_klass.respond_symbol] = normalizer_klass
    end

    def self.get(normalizer_sym)
      instance.plugin_map[normalizer_sym&.to_sym || Remocon::Type::VOID]
    end

    def plugin_map
      return @plugin_map if @plugin_map
      @plugin_map = {}

      Remocon::Normalizer.subclasses.each { |klass| Remocon::TypeNormalizerFactory.register(klass) }

      @plugin_map
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
remocon-0.5.1 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.5.0 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.4.4 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.4.3 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.4.2 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.4.1 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.4.0 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.4.0.pre.1 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.3.1 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.3.0 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.2.0 lib/remocon/normalizer/type_normalizer_factory.rb
remocon-0.1.0 lib/remocon/normalizer/type_normalizer_factory.rb