Class: Cabriolet::Plugin Abstract
- Inherits:
-
Object
- Object
- Cabriolet::Plugin
- Defined in:
- lib/cabriolet/plugin.rb
Overview
Base class for all Cabriolet plugins
Plugins extend Cabriolet’s functionality by providing custom compression algorithms, format handlers, or other enhancements. All plugins must inherit from this base class and implement required methods.
Constant Summary collapse
- STATES =
Plugin states
i[discovered loaded active failed disabled].freeze
Instance Attribute Summary collapse
-
#state ⇒ Symbol
readonly
Current plugin state.
Instance Method Summary collapse
-
#activate ⇒ void
Activate the plugin.
-
#cleanup ⇒ void
Cleanup the plugin.
-
#deactivate ⇒ void
Deactivate the plugin.
-
#initialize(manager = nil) ⇒ Plugin
constructor
Initialize a new plugin.
-
#metadata ⇒ Hash
abstract
Get plugin metadata.
-
#setup ⇒ Object
abstract
Setup the plugin.
Constructor Details
#initialize(manager = nil) ⇒ Plugin
Initialize a new plugin
40 41 42 43 |
# File 'lib/cabriolet/plugin.rb', line 40 def initialize(manager = nil) @manager = manager @state = :discovered end |
Instance Attribute Details
#state ⇒ Symbol (readonly)
Returns Current plugin state.
35 36 37 |
# File 'lib/cabriolet/plugin.rb', line 35 def state @state end |
Instance Method Details
#activate ⇒ void
This method returns an undefined value.
Activate the plugin
Called when the plugin is activated. Override to perform actions when the plugin becomes active.
134 135 136 |
# File 'lib/cabriolet/plugin.rb', line 134 def activate # Default implementation does nothing end |
#cleanup ⇒ void
This method returns an undefined value.
Cleanup the plugin
Called when the plugin is unloaded. Override to perform final cleanup tasks.
166 167 168 |
# File 'lib/cabriolet/plugin.rb', line 166 def cleanup # Default implementation does nothing end |
#deactivate ⇒ void
This method returns an undefined value.
Deactivate the plugin
Called when the plugin is deactivated. Override to perform cleanup when the plugin is deactivated.
150 151 152 |
# File 'lib/cabriolet/plugin.rb', line 150 def deactivate # Default implementation does nothing end |
#metadata ⇒ Hash
Must be implemented by subclasses
Get plugin metadata
91 92 93 94 |
# File 'lib/cabriolet/plugin.rb', line 91 def raise NotImplementedError, "#{self.class} must implement metadata method" end |
#setup ⇒ Object
Must be implemented by subclasses
Setup the plugin
Called when the plugin is loaded. Use this method to register algorithms, formats, or perform other initialization tasks.
117 118 119 120 |
# File 'lib/cabriolet/plugin.rb', line 117 def setup raise NotImplementedError, "#{self.class} must implement setup method" end |