Module: Kernel

Defined in:
lib/bel/vendor/little-plugger.rb

Instance Method Summary collapse

Instance Method Details

#LittlePlugger(opts = {}) ⇒ Object

call-seq:

LittlePlugger( opts = {} )

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.
    


302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/bel/vendor/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