Class: ActiveStorage::Previewer
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | activestorage/lib/active_storage/previewer.rb |
Overview
This is an abstract base class for previewers, which generate images from blobs. See MuPDFPreviewer
and VideoPreviewer
for examples of concrete subclasses.
Class Method Summary
-
.accept?(blob) ⇒ Boolean
Implement this method in a concrete subclass.
- .new(blob) ⇒ Previewer constructor
Instance Attribute Summary
- #blob readonly
Instance Method Summary
-
#preview(**options)
Override this method in a concrete subclass.
Constructor Details
.new(blob) ⇒ Previewer
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.
# File 'activestorage/lib/active_storage/previewer.rb', line 14
def self.accept?(blob) false end
Instance Attribute Details
#blob (readonly)
[ GitHub ]# File 'activestorage/lib/active_storage/previewer.rb', line 10
attr_reader :blob
Instance Method Details
#preview(**options)
Override this method in a concrete subclass. Have it yield an attachable preview image (i.e. anything accepted by Attached::One#attach). Pass the additional options to the underlying blob that is created.
# File 'activestorage/lib/active_storage/previewer.rb', line 25
def preview(** ) raise NotImplementedError end