Sha256: e47937e6a49aa2aeeeee8932a546d423240d7ff57789be248b3a5065abfb3ee8

Contents?: true

Size: 722 Bytes

Versions: 30

Compression:

Stored size: 722 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(&:load!)
    end

    private

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

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rollbar-2.19.2 lib/rollbar/plugins.rb
rollbar-2.19.1 lib/rollbar/plugins.rb
rollbar-2.19.0 lib/rollbar/plugins.rb
rollbar-2.18.2 lib/rollbar/plugins.rb
rollbar-2.18.0 lib/rollbar/plugins.rb
rollbar-2.17.0 lib/rollbar/plugins.rb
rollbar-2.16.4 lib/rollbar/plugins.rb
rollbar-2.16.3 lib/rollbar/plugins.rb
rollbar-2.16.2 lib/rollbar/plugins.rb
rollbar-2.16.0 lib/rollbar/plugins.rb
rollbar-2.15.6 lib/rollbar/plugins.rb
rollbar-2.15.5 lib/rollbar/plugins.rb
rollbar-2.15.4 lib/rollbar/plugins.rb
rollbar-2.15.3 lib/rollbar/plugins.rb
rollbar-2.15.2 lib/rollbar/plugins.rb
rollbar-2.15.1 lib/rollbar/plugins.rb
rollbar-2.15.0 lib/rollbar/plugins.rb
rollbar-2.14.1 lib/rollbar/plugins.rb
rollbar-2.14.0 lib/rollbar/plugins.rb
rollbar-2.13.3 lib/rollbar/plugins.rb