aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage/service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_storage/service.rb')
-rw-r--r--lib/active_storage/service.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/active_storage/service.rb b/lib/active_storage/service.rb
index 6978ce6429..021c695a07 100644
--- a/lib/active_storage/service.rb
+++ b/lib/active_storage/service.rb
@@ -32,15 +32,24 @@
class ActiveStorage::Service
class ActiveStorage::IntegrityError < StandardError; end
+ extend ActiveSupport::Autoload
+ autoload :Configurator
+
+ # Configure an Active Storage service by name from a set of configurations,
+ # typically loaded from a YAML file. The Active Storage engine uses this
+ # to set the global Active Storage service when the app boots.
def self.configure(service_name, configurations)
- require 'active_storage/service/configurator'
- Configurator.new(service_name, configurations).build
+ Configurator.build(service_name, configurations)
end
# Override in subclasses that stitch together multiple services and hence
- # need to do additional lookups from configurations. See MirrorService.
- def self.build(service_config, all_configurations) #:nodoc:
- new(service_config)
+ # need to build additional services using the configurator.
+ #
+ # Passes the configurator and all of the service's config as keyword args.
+ #
+ # See MirrorService for an example.
+ def self.build(configurator:, service: nil, **service_config) #:nodoc:
+ new(**service_config)
end
def upload(key, io, checksum: nil)