class Requirium::RequireLoader

Attributes

sym[R]

Public Class Methods

new(sym, paths, dirname = nil) click to toggle source
# File lib/require_loader.rb, line 5
def initialize(sym, paths, dirname = nil)
  @sym = sym
  @paths = clean_paths(paths, dirname)
end

Public Instance Methods

call(mod) click to toggle source
# File lib/require_loader.rb, line 10
def call(mod)
  @paths.each { |filename| mod.send(method, filename) }
  nil
end

Private Instance Methods

clean_paths(paths, dirname) click to toggle source
# File lib/require_loader.rb, line 17
def clean_paths(paths, dirname)
  paths = [*paths]
  paths = [sym.to_s.snakecase] if paths.empty?

  if dirname
    dirname = Pathname(dirname)
    paths.map! { |path| (dirname + path).to_s }
  end

  paths
end
method() click to toggle source
# File lib/require_loader.rb, line 29
def method
  :require
end