module Kernel

Public Instance Methods

LittlePlugger( opts = {} ) click to toggle source

This method allows the user to override some of LittlePlugger's default settings when mixed into a module or class.

See the “Customizing” section of the LittlePlugger documentation for an example of how this method is used.

Options

  • :path <String>

    The default plugin path. Defaults to "module_name/plugins".
  • :module <Module>

    The module where plugins will be loaded. Defaults to
    ModuleName::Plugins.
    
  • :plugins <Array>

    The array of default plugins to load. Only the plugins listed in this
    array will be loaded by LittlePlugger.
# File lib/little-plugger.rb, line 302
def LittlePlugger( opts = {} )
  return ::LittlePlugger::ClassMethods if opts.empty?
  Module.new {
    include ::LittlePlugger::ClassMethods

    if opts.key?(:path)
      eval %Q{def plugin_path() #{opts[:path].to_s.inspect} end}
    end

    if opts.key?(:module)
      eval %Q{def plugin_module() #{opts[:module].name} end}
    end

    if opts.key?(:plugins)
      plugins = Array(opts[:plugins]).map {|val| val.to_sym.inspect}.join(',')
      eval %Q{def plugin_names() @plugin_names ||= [#{plugins}] end}
    end
  }
end