class ActiveStorage::Service::Configurator
:nodoc:
def self.build(service_name, configurations)
def self.build(service_name, configurations) new(configurations).build(service_name) end
def build(service_name)
def build(service_name) config = config_for(service_name.to_sym) resolve(config.fetch(:service)).build( **config, configurator: self, name: service_name ) end
def config_for(name)
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
def initialize(configurations)
def initialize(configurations) @configurations = configurations.deep_symbolize_keys end
def resolve(class_name)
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