Module: Audioproxy::Rails::BlobResolver
- Defined in:
- lib/audioproxy/rails/blob_resolver.rb
Overview
Turns ActiveStorage objects into the source strings the proxy speaks. Registered with the core by the railtie; the core itself never names an ActiveStorage constant (D5).
Defined Under Namespace
Modules: DiskLayout
Constant Summary collapse
- SERVICES =
Dispatch is on the blob's service class, never on the configured service name — :amazon and :local are labels an app picks, and an app may well call its S3 service :local (D1).
Matched by class name rather than by constant, because naming ActiveStorage::Service::S3Service here would load its file, and that file requires aws-sdk-s3 — a gem an app storing on disk has no reason to bundle. Ancestor names, so an app's own subclass of a supported service resolves the way its parent does.
A Mirror service is not in this table and is not unwrapped to its primary (non-goal): it raises, naming the mirror, so the operator makes the choice of which service to point at rather than the gem guessing.
{ "ActiveStorage::Service::S3Service" => :s3, "ActiveStorage::Service::DiskService" => :disk }.freeze
- SUPPORTED =
"S3 and Disk".freeze
Class Method Summary collapse
Class Method Details
.call(source) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/audioproxy/rails/blob_resolver.rb', line 41 def call(source) blob = unwrap(source) service = blob.service case kind_of_service(service) when :s3 then "s3://#{bucket_for(service)}/#{blob.key}" when :disk then "local://#{DiskLayout.relative_path_for(blob.key)}" else raise UnsupportedServiceError, (service) end end |