class LogCabin::DirCollection

Define a collection of modules in a local dir

Attributes

load_path[R]

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method LogCabin::BaseCollection::new
# File lib/logcabin/dircollection.rb, line 7
def initialize(params = {})
  @load_path = params[:load_path] || raise('Load path must be provided')
  @load_path = [@load_path] if @load_path.is_a? String
  super
end

Public Instance Methods

find(name) click to toggle source

Method for finding modules to load

# File lib/logcabin/dircollection.rb, line 15
def find(name)
  cache(name) { load_class_from_module(find_file(name), name) }
end

Private Instance Methods

find_file(name) click to toggle source

Check module path for module

# File lib/logcabin/dircollection.rb, line 23
def find_file(name)
  @load_path.each do |dir|
    file_path = File.join(dir, "#{name}.rb")
    return file_path if File.exist? file_path
  end
  raise("Module #{name} not found")
end