Class: Inspec::Plugin::V2::Activator
- Inherits:
-
Struct
- Object
- Struct
- Inspec::Plugin::V2::Activator
- Defined in:
- lib/inspec/plugin/v2/activator.rb
Instance Attribute Summary collapse
-
#activated ⇒ Object
(also: #activated?)
Returns the value of attribute activated.
-
#activation_proc ⇒ Object
Returns the value of attribute activation_proc.
-
#activator_name ⇒ Object
Returns the value of attribute activator_name.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#implementation_class ⇒ Object
Returns the value of attribute implementation_class.
-
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
-
#plugin_type ⇒ Object
Returns the value of attribute plugin_type.
Instance Method Summary collapse
-
#activate ⇒ Object
Load a plugin, but if an error is encountered, store it and continue.
-
#activate! ⇒ Object
Load a plugin, but if an error is encountered, re-throw it.
-
#initialize ⇒ Activator
constructor
A new instance of Activator.
Constructor Details
#initialize ⇒ Activator
Returns a new instance of Activator.
11 12 13 14 |
# File 'lib/inspec/plugin/v2/activator.rb', line 11 def initialize(*) super self[:activated] = false end |
Instance Attribute Details
#activated ⇒ Object Also known as: activated?
Returns the value of attribute activated
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def activated @activated end |
#activation_proc ⇒ Object
Returns the value of attribute activation_proc
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def activation_proc @activation_proc end |
#activator_name ⇒ Object
Returns the value of attribute activator_name
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def activator_name @activator_name end |
#exception ⇒ Object
Returns the value of attribute exception
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def exception @exception end |
#implementation_class ⇒ Object
Returns the value of attribute implementation_class
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def implementation_class @implementation_class end |
#plugin_name ⇒ Object
Returns the value of attribute plugin_name
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def plugin_name @plugin_name end |
#plugin_type ⇒ Object
Returns the value of attribute plugin_type
2 3 4 |
# File 'lib/inspec/plugin/v2/activator.rb', line 2 def plugin_type @plugin_type end |
Instance Method Details
#activate ⇒ Object
Load a plugin, but if an error is encountered, store it and continue
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/inspec/plugin/v2/activator.rb', line 19 def activate return if activated? # rubocop: disable Lint/RescueException begin impl_class = self[:activation_proc].call self.activated = true self[:implementation_class] = impl_class rescue Exception => ex self[:exception] = ex Inspec::Log.error "Could not activate #{self[:plugin_type]} hook named '#{self[:activator_name]}' for plugin #{self[:plugin_name]}" end # rubocop: enable Lint/RescueException end |
#activate! ⇒ Object
Load a plugin, but if an error is encountered, re-throw it
35 36 37 38 |
# File 'lib/inspec/plugin/v2/activator.rb', line 35 def activate! activate raise exception if exception end |