Module: Sensu::Extensions

Defined in:
lib/sensu/extensions.rb,
lib/sensu/extensions/loader.rb

Defined Under Namespace

Classes: Loader

Class Method Summary collapse

Class Method Details

.get(options = {}) ⇒ Loader

Retrieve the current loaded extensions loader or load one up if there isn't one. Note: We may need to add a mutex for thread safety.


36
37
38
# File 'lib/sensu/extensions.rb', line 36

def get(options={})
  @loader || load(options)
end

.load(options = {}) ⇒ Loader

Load Sensu extensions.

Options Hash (options):

  • :extension_file (String)

    to load.

  • :extension_dir (String)

    to load.

  • :extension_dirs (Array)

    to load.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sensu/extensions.rb', line 13

def load(options={})
  @loader = Loader.new
  if options[:extension_file]
    @loader.load_file(options[:extension_file])
  end
  if options[:extension_dir]
    @loader.load_directory(options[:extension_dir])
  end
  if options[:extension_dirs]
    options[:extension_dirs].each do |directory|
      @loader.load_directory(directory)
    end
  end
  @loader.load_instances
  @loader
end