class Plugin

Attributes

logger[R]
options[R]

Public Class Methods

inherited(klass) click to toggle source
# File lib/snap_ebs/plugin.rb, line 7
def self.inherited(klass)
  registered_plugins.unshift klass
end
registered_plugins() click to toggle source
# File lib/snap_ebs/plugin.rb, line 11
def self.registered_plugins
  @@registered_plugins
end

Public Instance Methods

collect_options(option_parser) click to toggle source
# File lib/snap_ebs/plugin.rb, line 23
def collect_options option_parser
  option_parser.on "--#{name.downcase}", "Enable the #{name} plugin" do
    options.enable = true
  end

  defined_options.each do |option_name, description|
    option_parser.on "--#{name.downcase}-#{option_name.to_s.gsub('_','-')} #{option_name.upcase}", description do |val|
      options[option_name.to_sym] = val
    end
  end
end
default_options() click to toggle source
# File lib/snap_ebs/plugin.rb, line 15
def default_options
  { }
end

Protected Instance Methods

carefully(msg) { || ... } click to toggle source

Executes the given block with error handling, and prints helpful error messages when an exception is caught.

Returns the result of the block, or nil if an exception occured

“` carefully 'reticulate splines' do

splines.each &:reticulate

end “`

# File lib/snap_ebs/plugin.rb, line 48
def carefully msg
  yield
rescue => e
  logger.error "Error while trying to #{msg}"
  logger.error e
  nil
end