Module: Cms::Attachments::Serving
- Included in:
- Cms::AttachmentsController, ContentController
- Defined in:
- lib/cms/attachments/attachment_serving.rb
Overview
Can be added to Controllers to handle serving files.
Class Method Summary collapse
-
.send_attachments_with ⇒ #send_attachments
The strategy that will be used to serve files.
Instance Method Summary collapse
-
#send_attachment(attachment) ⇒ Object
Send the file if: 1.
- #send_attachments_with ⇒ Object
Class Method Details
.send_attachments_with ⇒ #send_attachments
Returns The strategy that will be used to serve files.
27 28 29 30 |
# File 'lib/cms/attachments/attachment_serving.rb', line 27 def self. storage = Rails.configuration.cms..storage "Cms::Attachments::#{storage.to_s.classify}Strategy".constantize end |
Instance Method Details
#send_attachment(attachment) ⇒ Object
Send the file if:
1. It exists:
2. The user has permissions to see it.
The strategy used to send the file can be configured based on the config.cms.attachments.storage parameter. Default is:
storage = :filesystem -> Cms::Attachments::FilesystemStrategy
14 15 16 17 18 19 20 |
# File 'lib/cms/attachments/attachment_serving.rb', line 14 def () if raise Cms::Errors::AccessDenied unless current_user.able_to_view?() strategy_class = strategy_class.(, self) end end |
#send_attachments_with ⇒ Object
22 23 24 |
# File 'lib/cms/attachments/attachment_serving.rb', line 22 def Cms::Attachments::Serving. end |