Class: Rollbar::Plugins
- Inherits:
-
Object
- Object
- Rollbar::Plugins
- Defined in:
- lib/rollbar/plugins.rb
Overview
Stores the available plugin definitions and loads them
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
- #define(name, &block) ⇒ Object
- #get(name) ⇒ Object
-
#initialize ⇒ Plugins
constructor
A new instance of Plugins.
- #load! ⇒ Object
- #plugin_files ⇒ Object
- #require_all ⇒ Object
Constructor Details
#initialize ⇒ Plugins
Returns a new instance of Plugins.
8 9 10 |
# File 'lib/rollbar/plugins.rb', line 8 def initialize @collection = [] end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
6 7 8 |
# File 'lib/rollbar/plugins.rb', line 6 def collection @collection end |
Instance Method Details
#define(name, &block) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/rollbar/plugins.rb', line 22 def define(name, &block) return if loaded?(name) plugin = Rollbar::Plugin.new(name) collection << plugin plugin.instance_eval(&block) end |
#get(name) ⇒ Object
37 38 39 |
# File 'lib/rollbar/plugins.rb', line 37 def get(name) collection.find { |plugin| plugin.name == name } end |
#load! ⇒ Object
31 32 33 34 35 |
# File 'lib/rollbar/plugins.rb', line 31 def load! collection.each do |plugin| plugin.load! unless plugin.on_demand end end |
#plugin_files ⇒ Object
18 19 20 |
# File 'lib/rollbar/plugins.rb', line 18 def plugin_files File.('../plugins/*.rb', __FILE__) end |
#require_all ⇒ Object
12 13 14 15 16 |
# File 'lib/rollbar/plugins.rb', line 12 def require_all Dir.glob(plugin_files).each do |file| require file.to_s end end |