aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage/service.rb
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2017-07-08 16:55:50 -0700
committerJeremy Daer <jeremydaer@gmail.com>2017-07-08 17:27:31 -0700
commite5503399c0bb992ec1fd47b4bc371b8aef679e37 (patch)
tree345c3428df076adee7b9478ad4ae105959b4e47e /lib/active_storage/service.rb
parent6116313da4996ef99dcb45e2b9ac90ef073caabc (diff)
downloadrails-e5503399c0bb992ec1fd47b4bc371b8aef679e37.tar.gz
rails-e5503399c0bb992ec1fd47b4bc371b8aef679e37.tar.bz2
rails-e5503399c0bb992ec1fd47b4bc371b8aef679e37.zip
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.
Diffstat (limited to 'lib/active_storage/service.rb')
-rw-r--r--lib/active_storage/service.rb16
1 files changed, 9 insertions, 7 deletions
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)