Class: Hako::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/hako/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_module, base_path) ⇒ Loader

Returns a new instance of Loader.

Parameters:

  • base_module (Module)
  • base_path (String)


7
8
9
10
# File 'lib/hako/loader.rb', line 7

def initialize(base_module, base_path)
  @base_module = base_module
  @base_path = base_path
end

Instance Method Details

#camelize(name) ⇒ String (private)

Parameters:

  • name (String)

Returns:

  • (String)


23
24
25
# File 'lib/hako/loader.rb', line 23

def camelize(name)
  name.split('_').map(&:capitalize).join('')
end

#load(name) ⇒ Module

Parameters:

  • name (String)

Returns:

  • (Module)


14
15
16
17
# File 'lib/hako/loader.rb', line 14

def load(name)
  require "#{@base_path}/#{name}"
  @base_module.const_get(camelize(name))
end