Class: RKit::Core::Loader::LoadPath
- Inherits:
-
Object
- Object
- RKit::Core::Loader::LoadPath
- Defined in:
- lib/r_kit/core/loader.rb
Instance Attribute Summary collapse
-
#_base ⇒ Object
Returns the value of attribute _base.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#file ⇒ Object
Returns the value of attribute file.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #exec_condition(statement, condition) ⇒ Object
- #exec_statement(statement, condition) ⇒ Object
- #extname ⇒ Object
- #fullpath ⇒ Object
-
#initialize(base, file:, path:) ⇒ LoadPath
constructor
A new instance of LoadPath.
- #load! ⇒ Object
- #load_path! ⇒ Object
- #should_load? ⇒ Boolean
Constructor Details
#initialize(base, file:, path:) ⇒ LoadPath
Returns a new instance of LoadPath.
59 60 61 62 63 64 |
# File 'lib/r_kit/core/loader.rb', line 59 def initialize base, file:, path:; @_base = base @file = file @path = path end |
Instance Attribute Details
#_base ⇒ Object
Returns the value of attribute _base.
56 57 58 |
# File 'lib/r_kit/core/loader.rb', line 56 def _base @_base end |
#conditions ⇒ Object
Returns the value of attribute conditions.
56 57 58 |
# File 'lib/r_kit/core/loader.rb', line 56 def conditions @conditions end |
#file ⇒ Object
Returns the value of attribute file.
56 57 58 |
# File 'lib/r_kit/core/loader.rb', line 56 def file @file end |
#path ⇒ Object
Returns the value of attribute path.
56 57 58 |
# File 'lib/r_kit/core/loader.rb', line 56 def path @path end |
Instance Method Details
#exec_condition(statement, condition) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/r_kit/core/loader.rb', line 92 def exec_condition statement, condition condition = case condition when Proc condition.call _base::CONFIG when Symbol, String _base::CONFIG.send condition end exec_statement statement, condition end |
#exec_statement(statement, condition) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/r_kit/core/loader.rb', line 103 def exec_statement statement, condition case statement when :if !!condition when :unless !condition end end |
#extname ⇒ Object
67 68 69 |
# File 'lib/r_kit/core/loader.rb', line 67 def extname File.extname(file) end |
#fullpath ⇒ Object
71 72 73 74 |
# File 'lib/r_kit/core/loader.rb', line 71 def fullpath file.chomp! File.extname(file) File.(path, file) end |
#load! ⇒ Object
87 88 89 |
# File 'lib/r_kit/core/loader.rb', line 87 def load! load_path! if should_load? end |
#load_path! ⇒ Object
83 84 85 |
# File 'lib/r_kit/core/loader.rb', line 83 def load_path! require fullpath end |
#should_load? ⇒ Boolean
77 78 79 80 81 |
# File 'lib/r_kit/core/loader.rb', line 77 def should_load? conditions.inject(true) do |should_load, (statement, condition)| should_load && exec_condition(statement, condition) end end |