Class: RKit::Core::Loader
- Inherits:
-
Object
- Object
- RKit::Core::Loader
show all
- Defined in:
- lib/r_kit/core/loader.rb
Defined Under Namespace
Classes: Dependency, LoadPath
Constant Summary
collapse
- @@loaded =
[]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(base) ⇒ Loader
Returns a new instance of Loader.
6
7
8
9
10
|
# File 'lib/r_kit/core/loader.rb', line 6
def initialize base
@_base = base
@load_paths = []
@dependencies = []
end
|
Instance Attribute Details
#_base ⇒ Object
Returns the value of attribute _base.
2
3
4
|
# File 'lib/r_kit/core/loader.rb', line 2
def _base
@_base
end
|
#dependencies ⇒ Object
Returns the value of attribute dependencies.
2
3
4
|
# File 'lib/r_kit/core/loader.rb', line 2
def dependencies
@dependencies
end
|
#load_paths ⇒ Object
Returns the value of attribute load_paths.
2
3
4
|
# File 'lib/r_kit/core/loader.rb', line 2
def load_paths
@load_paths
end
|
Instance Method Details
#dependencies! ⇒ Object
17
18
19
|
# File 'lib/r_kit/core/loader.rb', line 17
def dependencies!
dependencies.each &:load!
end
|
#dependency(dependency) ⇒ Object
13
14
15
|
# File 'lib/r_kit/core/loader.rb', line 13
def dependency dependency
dependencies << Dependency.new(_base, str: dependency)
end
|
#load! ⇒ Object
39
40
41
42
43
|
# File 'lib/r_kit/core/loader.rb', line 39
def load!
dependencies!
load_paths!
loaded!
end
|
#load_path(file, path, options = {}) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/r_kit/core/loader.rb', line 22
def load_path file, path, options = {}
load_path = LoadPath.new _base, file: file, path: path
load_path.conditions = options.slice :if, :unless
load_paths << load_path
end
|
#load_paths! ⇒ Object
29
30
31
|
# File 'lib/r_kit/core/loader.rb', line 29
def load_paths!
load_paths.each &:load!
end
|
#loaded! ⇒ Object
34
35
36
|
# File 'lib/r_kit/core/loader.rb', line 34
def loaded!
@@loaded << _base.name.demodulize.underscore
end
|