Class: ActiveStorage::Previewer
- Defined in:
- activestorage/lib/active_storage/previewer.rb
Overview
Active Storage Previewer
This is an abstract base class for previewers, which generate images from blobs. See ActiveStorage::Previewer::MuPDFPreviewer and ActiveStorage::Previewer::VideoPreviewer for examples of concrete subclasses.
Direct Known Subclasses
Defined Under Namespace
Classes: MuPDFPreviewer, PopplerPDFPreviewer, VideoPreviewer
Instance Attribute Summary collapse
-
#blob ⇒ Object
readonly
Returns the value of attribute blob.
Class Method Summary collapse
-
.accept?(blob) ⇒ Boolean
Implement this method in a concrete subclass.
Instance Method Summary collapse
-
#initialize(blob) ⇒ Previewer
constructor
A new instance of Previewer.
-
#preview(**options) ⇒ Object
Override this method in a concrete subclass.
Constructor Details
#initialize(blob) ⇒ Previewer
Returns a new instance of Previewer.
18 19 20 |
# File 'activestorage/lib/active_storage/previewer.rb', line 18 def initialize(blob) @blob = blob end |
Instance Attribute Details
#blob ⇒ Object (readonly)
Returns the value of attribute blob
10 11 12 |
# File 'activestorage/lib/active_storage/previewer.rb', line 10 def blob @blob end |
Class Method Details
.accept?(blob) ⇒ Boolean
Implement this method in a concrete subclass. Have it return true when given a blob from which the previewer can generate an image.
14 15 16 |
# File 'activestorage/lib/active_storage/previewer.rb', line 14 def self.accept?(blob) false end |
Instance Method Details
#preview(**options) ⇒ Object
Override this method in a concrete subclass. Have it yield an attachable preview image (i.e. anything accepted by ActiveStorage::Attached::One#attach). Pass the additional options to the underlying blob that is created.
25 26 27 |
# File 'activestorage/lib/active_storage/previewer.rb', line 25 def preview(**) raise NotImplementedError end |