From e5503399c0bb992ec1fd47b4bc371b8aef679e37 Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Sat, 8 Jul 2017 16:55:50 -0700 Subject: Configure services that reference other services * Move service configuration from the Engine to Service * Delegate configuration mechanics to internal Service::Configurator * Delegate service building to the concrete Service classes, allowing them to configure composed services. * Implement for the Mirror service. --- lib/active_storage/service.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/active_storage/service.rb') diff --git a/lib/active_storage/service.rb b/lib/active_storage/service.rb index f15958fda9..1a6a55739f 100644 --- a/lib/active_storage/service.rb +++ b/lib/active_storage/service.rb @@ -32,13 +32,15 @@ class ActiveStorage::Service class ActiveStorage::IntegrityError < StandardError; end - def self.configure(service, **options) - begin - require "active_storage/service/#{service.to_s.downcase}_service" - ActiveStorage::Service.const_get(:"#{service}Service").new(**options) - rescue LoadError => e - puts "Couldn't configure service: #{service} (#{e.message})" - end + def self.configure(service_name, configurations) + require 'active_storage/service/configurator' + Configurator.new(service_name, configurations).build + end + + # Override in subclasses that stitch together multiple services and hence + # need to do additional lookups from configurations. See MirrorService. + def self.build(config, configurations) #:nodoc: + new(config) end def upload(key, io, checksum: nil) -- cgit v1.2.3