diff options
author | claudiob <claudiob@users.noreply.github.com> | 2017-08-04 16:33:40 -0700 |
---|---|---|
committer | claudiob <claudiob@users.noreply.github.com> | 2017-08-04 16:40:10 -0700 |
commit | bb7599a6c84aba44cbb5f21486ffdb4a549717dd (patch) | |
tree | 26dd9fba5a7f6c09fbfcec9fbf29b7088db88411 /activestorage/lib/active_storage/attached.rb | |
parent | 552840660389e39f3ba8e47dcf35ab817c01cb48 (diff) | |
download | rails-bb7599a6c84aba44cbb5f21486ffdb4a549717dd.tar.gz rails-bb7599a6c84aba44cbb5f21486ffdb4a549717dd.tar.bz2 rails-bb7599a6c84aba44cbb5f21486ffdb4a549717dd.zip |
`module ActiveStorage`, not `ActiveStorage::Class`
The reasons for this commit are:
- uniformity with the other Rails libraries
- (possibly) behave better with respect to autoloading
- fix the index in the generated documentation
Before this commit, run `rake rdoc` generates this left sidebar
(ActiveStorage entries are indexed twice, both inside and outside the module):
<img width="308" alt="before" src="https://user-images.githubusercontent.com/10076/28939523-7c087dec-7846-11e7-9289-38ed4a2930cd.png">
After this commit, run `rake rdoc` generates this left sidebar:
(ActiveStorage entries are only indexed inside the module):
<img width="303" alt="after" src="https://user-images.githubusercontent.com/10076/28939524-7c090be0-7846-11e7-8ee5-29dfecae548e.png">
Diffstat (limited to 'activestorage/lib/active_storage/attached.rb')
-rw-r--r-- | activestorage/lib/active_storage/attached.rb | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/activestorage/lib/active_storage/attached.rb b/activestorage/lib/active_storage/attached.rb index 2dbf841864..5ac8ba5377 100644 --- a/activestorage/lib/active_storage/attached.rb +++ b/activestorage/lib/active_storage/attached.rb @@ -2,33 +2,35 @@ require "action_dispatch" require "action_dispatch/http/upload" require "active_support/core_ext/module/delegation" +module ActiveStorage # Abstract baseclass for the concrete `ActiveStorage::Attached::One` and `ActiveStorage::Attached::Many` # classes that both provide proxy access to the blob association for a record. -class ActiveStorage::Attached - attr_reader :name, :record + class Attached + attr_reader :name, :record - def initialize(name, record) - @name, @record = name, record - end + def initialize(name, record) + @name, @record = name, record + end - private - def create_blob_from(attachable) - case attachable - when ActiveStorage::Blob - attachable - when ActionDispatch::Http::UploadedFile - ActiveStorage::Blob.create_after_upload! \ - io: attachable.open, - filename: attachable.original_filename, - content_type: attachable.content_type - when Hash - ActiveStorage::Blob.create_after_upload!(attachable) - when String - ActiveStorage::Blob.find_signed(attachable) - else - nil + private + def create_blob_from(attachable) + case attachable + when ActiveStorage::Blob + attachable + when ActionDispatch::Http::UploadedFile + ActiveStorage::Blob.create_after_upload! \ + io: attachable.open, + filename: attachable.original_filename, + content_type: attachable.content_type + when Hash + ActiveStorage::Blob.create_after_upload!(attachable) + when String + ActiveStorage::Blob.find_signed(attachable) + else + nil + end end - end + end end require "active_storage/attached/one" |