Sha256: b85501aecc93ce5f7506838aadf51608eac96f8809152597229fcf9ac2a3e06c

Contents?: true

Size: 858 Bytes

Versions: 78

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

module ActiveStorage
  class Service::Registry # :nodoc:
    def initialize(configurations)
      @configurations = configurations.deep_symbolize_keys
      @services = {}
    end

    def fetch(name)
      services.fetch(name.to_sym) do |key|
        if configurations.include?(key)
          services[key] = configurator.build(key)
        else
          if block_given?
            yield key
          else
            raise KeyError, "Missing configuration for the #{key} Active Storage service. " \
              "Configurations available for the #{configurations.keys.to_sentence} services."
          end
        end
      end
    end

    private
      attr_reader :configurations, :services

      def configurator
        @configurator ||= ActiveStorage::Service::Configurator.new(configurations)
      end
  end
end

Version data entries

78 entries across 75 versions & 8 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activestorage-7.0.8.7/lib/active_storage/service/registry.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activestorage-7.1.3.4/lib/active_storage/service/registry.rb
activestorage-8.0.1 lib/active_storage/service/registry.rb
activestorage-8.0.0.1 lib/active_storage/service/registry.rb
activestorage-7.2.2.1 lib/active_storage/service/registry.rb
activestorage-7.1.5.1 lib/active_storage/service/registry.rb
activestorage-7.0.8.7 lib/active_storage/service/registry.rb
activestorage-8.0.0 lib/active_storage/service/registry.rb
activestorage-7.2.2 lib/active_storage/service/registry.rb
activestorage-7.1.5 lib/active_storage/service/registry.rb
activestorage-8.0.0.rc2 lib/active_storage/service/registry.rb
activestorage-7.2.1.2 lib/active_storage/service/registry.rb
activestorage-7.1.4.2 lib/active_storage/service/registry.rb
activestorage-7.0.8.6 lib/active_storage/service/registry.rb
activestorage-8.0.0.rc1 lib/active_storage/service/registry.rb
activestorage-7.2.1.1 lib/active_storage/service/registry.rb
activestorage-7.1.4.1 lib/active_storage/service/registry.rb
activestorage-7.0.8.5 lib/active_storage/service/registry.rb
activestorage-8.0.0.beta1 lib/active_storage/service/registry.rb
omg-activestorage-8.0.0.alpha9 lib/active_storage/service/registry.rb