123456789_123456789_123456789_123456789_123456789_

Class: ActiveStorage::Service::Registry

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activestorage/lib/active_storage/service/registry.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(configurations) ⇒ Registry

[ GitHub ]

  
# File 'activestorage/lib/active_storage/service/registry.rb', line 5

def initialize(configurations)
  @configurations = configurations.deep_symbolize_keys
  @services = {}
end

Instance Attribute Details

#configurations (readonly, private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/service/registry.rb', line 26

attr_reader :configurations, :services

#services (readonly, private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/service/registry.rb', line 26

attr_reader :configurations, :services

Instance Method Details

#configurator (private)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/service/registry.rb', line 28

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

#fetch(name)

[ GitHub ]

  
# File 'activestorage/lib/active_storage/service/registry.rb', line 10

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