diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-24 15:36:30 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-07-24 15:36:33 -0500 |
commit | 92536c08d53c5d54f6c526bfdc5d854dd00a7a88 (patch) | |
tree | bce150413987c2a3e11c9fdb0707057e211e0f00 /lib/active_storage/service/mirror_service.rb | |
parent | 87cb0063742f9d5672f69f623be8fe1dee79b223 (diff) | |
download | rails-92536c08d53c5d54f6c526bfdc5d854dd00a7a88.tar.gz rails-92536c08d53c5d54f6c526bfdc5d854dd00a7a88.tar.bz2 rails-92536c08d53c5d54f6c526bfdc5d854dd00a7a88.zip |
Document the rest of lib
Diffstat (limited to 'lib/active_storage/service/mirror_service.rb')
-rw-r--r-- | lib/active_storage/service/mirror_service.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/active_storage/service/mirror_service.rb b/lib/active_storage/service/mirror_service.rb index 54465cad05..7c407f2730 100644 --- a/lib/active_storage/service/mirror_service.rb +++ b/lib/active_storage/service/mirror_service.rb @@ -1,5 +1,8 @@ require "active_support/core_ext/module/delegation" +# Wraps a set of mirror services and provides a single `ActiveStorage::Service` object that will all +# have the files uploaded to them. A `primary` service is designated to answer calls to `download`, `exists?`, +# and `url`. class ActiveStorage::Service::MirrorService < ActiveStorage::Service attr_reader :primary, :mirrors @@ -16,12 +19,15 @@ class ActiveStorage::Service::MirrorService < ActiveStorage::Service @primary, @mirrors = primary, mirrors end + # Upload the `io` to the `key` specified to all services. If a `checksum` is provided, all services will + # ensure a match when the upload has completed or raise an `ActiveStorage::IntegrityError`. def upload(key, io, checksum: nil) each_service.collect do |service| service.upload key, io.tap(&:rewind), checksum: checksum end end + # Delete the file at the `key` on all services. def delete(key) perform_across_services :delete, key end |