Sha256: f5656c439b27ba9c1f8a3ac127bec3431e6710185eb2bd5e6d2421bce3c54fd3

Contents?: true

Size: 541 Bytes

Versions: 2

Compression:

Stored size: 541 Bytes

Contents

# frozen_string_literal: true

module Qyu
  # Qyu::Factory
  class Factory
    class ServiceFactory
      class << self
        def register(adapter_class)
          types[adapter_class::TYPE] = adapter_class
        end

        def types
          @__types ||= {}
        end

        def get(config)
          Qyu.logger.info "Got factory #{types[config[:type]]}"
          types[config[:type]].new(config)
        end
      end
    end

    class QueueFactory < ServiceFactory; end
    class StoreFactory < ServiceFactory; end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qyu-1.0.1 lib/qyu/factory.rb
qyu-1.0.0 lib/qyu/factory.rb