Class: Rollbar::Plugins

Inherits:
Object
  • Object
show all
Defined in:
lib/rollbar/plugins.rb

Overview

Stores the available plugin definitions and loads them

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePlugins

Returns a new instance of Plugins.



8
9
10
# File 'lib/rollbar/plugins.rb', line 8

def initialize
  @collection = []
end

Instance Attribute Details

#collectionObject (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_filesObject



18
19
20
# File 'lib/rollbar/plugins.rb', line 18

def plugin_files
  File.expand_path('../plugins/*.rb', __FILE__)
end

#require_allObject



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