# class Plugins - RDoc Documentation

# class Plugins

### Attributes

option_parser[R]

### Public Class Methods

new(option_parser = nil) click to toggle source

    # File lib/common/plugins/plugins.rb, line 6
    def initialize(option_parser = nil)
      if option_parser
        if option_parser.is_a?(CustomOptionParser)
          @option_parser = option_parser
        else
          raise "The parser must be an instance of CustomOptionParser, #{option_parser.class} supplied"
        end
      else
        @option_parser = CustomOptionParser.new
      end
    end

### Public Instance Methods

register(*plugins) click to toggle source

param Array(Plugin) plugins

    # File lib/common/plugins/plugins.rb, line 19
    def register(*plugins)
      plugins.each do |plugin|
        register_plugin(plugin)
      end
    end

register_plugin(plugin) click to toggle source

param Plugin plugin

    # File lib/common/plugins/plugins.rb, line 26
    def register_plugin(plugin)
      if plugin.is_a?(Plugin)
        self << plugin

        # A plugin may not have options
        if plugin_options = plugin.registered_options
          @option_parser.add(plugin_options)
        end
      else
        raise "The argument must be an instance of Plugin, #{plugin.class} supplied"
      end
    end