diff options
author | George Claghorn <george.claghorn@gmail.com> | 2018-02-07 22:31:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-07 22:31:32 -0500 |
commit | cc523fba9baf09849aeb59db28dab04135839f34 (patch) | |
tree | b6b4d41c7a1e90dbb61218b5f2a4bb0fc180bc7a /activestorage/app/models/active_storage/filename.rb | |
parent | 5ae2ecab6d3365f6f17e3c8cb298dfeeea113774 (diff) | |
parent | 0625a2ba80476bf0139f2ecb9019dc2c82e4a7de (diff) | |
download | rails-cc523fba9baf09849aeb59db28dab04135839f34.tar.gz rails-cc523fba9baf09849aeb59db28dab04135839f34.tar.bz2 rails-cc523fba9baf09849aeb59db28dab04135839f34.zip |
Merge pull request #31918 from huacnlee/fix/blob-service-url-for-string-filename
Fix `blob.service_url` for supports string type `:filename` option
Diffstat (limited to 'activestorage/app/models/active_storage/filename.rb')
-rw-r--r-- | activestorage/app/models/active_storage/filename.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activestorage/app/models/active_storage/filename.rb b/activestorage/app/models/active_storage/filename.rb index b9413dec95..2b8880716e 100644 --- a/activestorage/app/models/active_storage/filename.rb +++ b/activestorage/app/models/active_storage/filename.rb @@ -5,6 +5,14 @@ class ActiveStorage::Filename include Comparable + class << self + # Returns a Filename instance based on the given filename. If the filename is a Filename, it is + # returned unmodified. If it is a String, it is passed to ActiveStorage::Filename.new. + def wrap(filename) + filename.kind_of?(self) ? filename : new(filename) + end + end + def initialize(filename) @filename = filename end |