Class: Vedeu::Plugin
- Inherits:
-
Object
- Object
- Vedeu::Plugin
- Defined in:
- lib/vedeu/plugins/plugin.rb
Overview
A class responsible for plugin loading.
Instance Attribute Summary collapse
- #enabled ⇒ Boolean (also: #enabled?)
- #gem ⇒ String readonly
- #gem_name ⇒ String readonly
- #name ⇒ String|Symbol readonly
Instance Method Summary collapse
-
#initialize(name, gem) ⇒ Vedeu::Plugin
constructor
Returns a new instance of Vedeu::Plugin.
-
#load! ⇒ void
Load the plugin (require the gem).
Constructor Details
#initialize(name, gem) ⇒ Vedeu::Plugin
Returns a new instance of Vedeu::Plugin.
31 32 33 34 35 36 |
# File 'lib/vedeu/plugins/plugin.rb', line 31 def initialize(name, gem) @name = name @gem = gem @gem_name = "vedeu_#{name}" @enabled = false end |
Instance Attribute Details
#enabled ⇒ Boolean Also known as: enabled?
23 24 25 |
# File 'lib/vedeu/plugins/plugin.rb', line 23 def enabled @enabled end |
#gem ⇒ String (readonly)
15 16 17 |
# File 'lib/vedeu/plugins/plugin.rb', line 15 def gem @gem end |
#gem_name ⇒ String (readonly)
19 20 21 |
# File 'lib/vedeu/plugins/plugin.rb', line 19 def gem_name @gem_name end |
#name ⇒ String|Symbol (readonly)
11 12 13 |
# File 'lib/vedeu/plugins/plugin.rb', line 11 def name @name end |
Instance Method Details
#load! ⇒ void
This method returns an undefined value.
Load the plugin (require the gem).
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vedeu/plugins/plugin.rb', line 41 def load! begin require gem_name unless enabled? rescue LoadError => error raise Vedeu::Error::Fatal, "Unable to load plugin #{gem_name} due to #{error}." rescue => error raise Vedeu::Error::Fatal, "require '#{gem_name}' failed with #{error}." end @enabled = true end |