Class: ActiveStorage::Service::Configurator
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activestorage/lib/active_storage/service/configurator.rb |
Class Method Summary
Instance Attribute Summary
- #configurations readonly
Instance Method Summary
- #build(service_name)
- #config_for(name) private
- #resolve(class_name) private
Constructor Details
.new(configurations) ⇒ Configurator
# File 'activestorage/lib/active_storage/service/configurator.rb', line 11
def initialize(configurations) @configurations = configurations.deep_symbolize_keys end
Class Method Details
.build(service_name, configurations)
[ GitHub ]# File 'activestorage/lib/active_storage/service/configurator.rb', line 7
def self.build(service_name, configurations) new(configurations).build(service_name) end
Instance Attribute Details
#configurations (readonly)
[ GitHub ]# File 'activestorage/lib/active_storage/service/configurator.rb', line 5
attr_reader :configurations
Instance Method Details
#build(service_name)
[ GitHub ]# File 'activestorage/lib/active_storage/service/configurator.rb', line 15
def build(service_name) config = config_for(service_name.to_sym) resolve(config.fetch(:service)).build( **config, configurator: self, name: service_name ) end
#config_for(name) (private)
[ GitHub ]# File 'activestorage/lib/active_storage/service/configurator.rb', line 23
def config_for(name) configurations.fetch name do raise "Missing configuration for the #{name.inspect} Active Storage service. Configurations available for #{configurations.keys.inspect}" end end
#resolve(class_name) (private)
[ GitHub ]# File 'activestorage/lib/active_storage/service/configurator.rb', line 29
def resolve(class_name) require "active_storage/service/#{class_name.to_s.underscore}_service" ActiveStorage::Service.const_get(:"#{class_name.camelize}Service") rescue LoadError raise "Missing service adapter for #{class_name.inspect}" end