Class: Rollbar::Plugin
- Inherits:
-
Object
- Object
- Rollbar::Plugin
- Defined in:
- lib/rollbar/plugin.rb
Overview
Represents a plugin in the gem. Every plugin can have multiple dependencies and multiple execution blocks. On Rollbar initialization, all plugins will be saved in memory and those that satisfy the dependencies will be loaded
Instance Attribute Summary collapse
-
#callables ⇒ Object
readonly
Returns the value of attribute callables.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#loaded ⇒ Object
readonly
Returns the value of attribute loaded.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #configuration ⇒ Object
- #execute(&block) ⇒ Object
- #execute!(&block) ⇒ Object
-
#initialize(name) ⇒ Plugin
constructor
A new instance of Plugin.
- #load! ⇒ Object
Constructor Details
#initialize(name) ⇒ Plugin
Returns a new instance of Plugin.
14 15 16 17 18 19 |
# File 'lib/rollbar/plugin.rb', line 14 def initialize(name) @name = name @dependencies = [] @callables = [] @loaded = false end |
Instance Attribute Details
#callables ⇒ Object (readonly)
Returns the value of attribute callables.
9 10 11 |
# File 'lib/rollbar/plugin.rb', line 9 def callables @callables end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
8 9 10 |
# File 'lib/rollbar/plugin.rb', line 8 def dependencies @dependencies end |
#loaded ⇒ Object
Returns the value of attribute loaded.
10 11 12 |
# File 'lib/rollbar/plugin.rb', line 10 def loaded @loaded end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rollbar/plugin.rb', line 7 def name @name end |
Instance Method Details
#configuration ⇒ Object
21 22 23 |
# File 'lib/rollbar/plugin.rb', line 21 def configuration Rollbar.configuration end |
#execute(&block) ⇒ Object
37 38 39 |
# File 'lib/rollbar/plugin.rb', line 37 def execute(&block) callables << block end |
#execute!(&block) ⇒ Object
41 42 43 |
# File 'lib/rollbar/plugin.rb', line 41 def execute!(&block) block.call if load? end |
#load! ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rollbar/plugin.rb', line 25 def load! return unless load? begin callables.each(&:call) rescue => e log_loading_error(e) ensure self.loaded = true end end |