Sha256: 24370396568dd7ad7fa09be0b956a08312087b84632e10f33de4dff284868196

Contents?: true

Size: 862 Bytes

Versions: 35

Compression:

Stored size: 862 Bytes

Contents

require 'rollbar/plugin'

module Rollbar
  # Stores the available plugin definitions and loads them
  class Plugins
    attr_reader :collection

    def initialize
      @collection = []
    end

    def require_all
      Dir.glob(plugin_files).each do |file|
        require file.to_s
      end
    end

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

    def define(name, &block)
      return if loaded?(name)

      plugin = Rollbar::Plugin.new(name)
      collection << plugin

      plugin.instance_eval(&block)
    end

    def load!
      collection.each do |plugin|
        plugin.load! unless plugin.on_demand
      end
    end

    def get(name)
      collection.find { |plugin| plugin.name == name }
    end

    private

    def loaded?(name)
      collection.any? { |plugin| plugin.name == name }
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
rollbar-3.6.0 lib/rollbar/plugins.rb
rollbar-3.5.2 lib/rollbar/plugins.rb
rollbar-3.5.1 lib/rollbar/plugins.rb
rollbar-3.5.0 lib/rollbar/plugins.rb
rollbar-3.4.2 lib/rollbar/plugins.rb
rollbar-3.4.1 lib/rollbar/plugins.rb
rollbar-3.4.0 lib/rollbar/plugins.rb
rollbar-3.3.3 lib/rollbar/plugins.rb
rollbar-3.3.2 lib/rollbar/plugins.rb
rollbar-3.3.1 lib/rollbar/plugins.rb
rollbar-3.3.0 lib/rollbar/plugins.rb
rollbar-3.2.0 lib/rollbar/plugins.rb
rollbar-3.1.2 lib/rollbar/plugins.rb
rollbar-3.1.1 lib/rollbar/plugins.rb
rollbar-3.1.0 lib/rollbar/plugins.rb
rollbar-3.0.1 lib/rollbar/plugins.rb
rollbar-3.0.0 lib/rollbar/plugins.rb
rollbar-2.27.1 lib/rollbar/plugins.rb
rollbar-2.27.0 lib/rollbar/plugins.rb
rollbar-2.26.1 lib/rollbar/plugins.rb