diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2017-07-09 04:23:21 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-07-09 04:46:59 -0700 |
commit | 4d292fc0e75e35e177806b1ea821455fc0bc021c (patch) | |
tree | 6d81c06d71b8a6428a3b6edceb334fdb9ea6cabb /lib/active_storage/service/mirror_service.rb | |
parent | 1a17cfb9d9719c8458fb1259371c173627b96d8f (diff) | |
download | rails-4d292fc0e75e35e177806b1ea821455fc0bc021c.tar.gz rails-4d292fc0e75e35e177806b1ea821455fc0bc021c.tar.bz2 rails-4d292fc0e75e35e177806b1ea821455fc0bc021c.zip |
Clarify how a service can build other composed services
* Service.build takes the literal YAML config hash for the service and a
reference to the Configurator that's doing the building.
* Services that compose additional services can use the Configurator to
look them up and build them by name. See MirrorService for an example.
References #23
Diffstat (limited to 'lib/active_storage/service/mirror_service.rb')
-rw-r--r-- | lib/active_storage/service/mirror_service.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/active_storage/service/mirror_service.rb b/lib/active_storage/service/mirror_service.rb index 8a51a75684..54465cad05 100644 --- a/lib/active_storage/service/mirror_service.rb +++ b/lib/active_storage/service/mirror_service.rb @@ -5,15 +5,11 @@ class ActiveStorage::Service::MirrorService < ActiveStorage::Service delegate :download, :exist?, :url, to: :primary - # Stitch together from named configuration. - def self.build(service_config, all_configurations) #:nodoc: - primary = ActiveStorage::Service.configure(service_config.fetch(:primary), all_configurations) - - mirrors = service_config.fetch(:mirrors).collect do |service_name| - ActiveStorage::Service.configure(service_name.to_sym, all_configurations) - end - - new primary: primary, mirrors: mirrors + # Stitch together from named services. + def self.build(primary:, mirrors:, configurator:, **options) #:nodoc: + new \ + primary: configurator.build(primary), + mirrors: mirrors.collect { |name| configurator.build name } end def initialize(primary:, mirrors:) |