Class: Hako::Loader
- Inherits:
-
Object
- Object
- Hako::Loader
- Defined in:
- lib/hako/loader.rb
Instance Method Summary collapse
- #camelize(name) ⇒ String private
-
#initialize(base_module, base_path) ⇒ Loader
constructor
A new instance of Loader.
- #load(name) ⇒ Module
Constructor Details
#initialize(base_module, base_path) ⇒ Loader
Returns a new instance of Loader.
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)
23 24 25 |
# File 'lib/hako/loader.rb', line 23 def camelize(name) name.split('_').map(&:capitalize).join('') end |
#load(name) ⇒ 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 |