Class: ActiveStorageValidations::Analyzer
- Inherits:
-
Object
- Object
- ActiveStorageValidations::Analyzer
- Includes:
- ASVAttachable, ASVCommandable, ASVLoggable
- Defined in:
- lib/active_storage_validations/analyzer.rb
Overview
Active Storage Validations Analyzer
This is an abstract base class for analyzers, which extract metadata from attachables. See ActiveStorageValidations::Analyzer::VideoAnalyzer for an example of a concrete subclass.
Heavily (not to say 100%) inspired by Rails own ActiveStorage::Analyzer
Defined Under Namespace
Classes: AudioAnalyzer, ContentTypeAnalyzer, ImageAnalyzer, NullAnalyzer, PdfAnalyzer, VideoAnalyzer
Constant Summary
Constants included from ASVCommandable
ActiveStorageValidations::ASVCommandable::TERM_GRACE_SECONDS
Instance Attribute Summary collapse
-
#attachable ⇒ Object
readonly
Returns the value of attribute attachable.
Instance Method Summary collapse
-
#content_type ⇒ Object
Override this method in a concrete subclass.
-
#initialize(attachable, timeout: ActiveStorageValidations.command_timeout) ⇒ Analyzer
constructor
A new instance of Analyzer.
-
#metadata ⇒ Object
Override this method in a concrete subclass.
Methods included from ASVLoggable
Constructor Details
#initialize(attachable, timeout: ActiveStorageValidations.command_timeout) ⇒ Analyzer
Returns a new instance of Analyzer.
21 22 23 24 |
# File 'lib/active_storage_validations/analyzer.rb', line 21 def initialize(attachable, timeout: ActiveStorageValidations.command_timeout) @attachable = attachable @timeout = timeout end |
Instance Attribute Details
#attachable ⇒ Object (readonly)
Returns the value of attribute attachable.
19 20 21 |
# File 'lib/active_storage_validations/analyzer.rb', line 19 def attachable @attachable end |
Instance Method Details
#content_type ⇒ Object
Override this method in a concrete subclass. Have it return a String content type.
27 28 29 |
# File 'lib/active_storage_validations/analyzer.rb', line 27 def content_type raise NotImplementedError end |
#metadata ⇒ Object
Override this method in a concrete subclass. Have it return a Hash of metadata.
32 33 34 |
# File 'lib/active_storage_validations/analyzer.rb', line 32 def raise NotImplementedError end |