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.
50 51 52 53 54 55 |
# File 'lib/r_kit/core/loader.rb', line 50 def initialize base, file:, path:; @_base = base @file = file @path = path end |
Instance Attribute Details
#_base ⇒ Object
Returns the value of attribute _base.
47 48 49 |
# File 'lib/r_kit/core/loader.rb', line 47 def _base @_base end |
#conditions ⇒ Object
Returns the value of attribute conditions.
47 48 49 |
# File 'lib/r_kit/core/loader.rb', line 47 def conditions @conditions end |
#file ⇒ Object
Returns the value of attribute file.
47 48 49 |
# File 'lib/r_kit/core/loader.rb', line 47 def file @file end |
#path ⇒ Object
Returns the value of attribute path.
47 48 49 |
# File 'lib/r_kit/core/loader.rb', line 47 def path @path end |
Instance Method Details
#exec_condition(statement, condition) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/r_kit/core/loader.rb', line 83 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
94 95 96 97 98 99 100 101 |
# File 'lib/r_kit/core/loader.rb', line 94 def exec_statement statement, condition case statement when :if !!condition when :unless !condition end end |
#extname ⇒ Object
58 59 60 |
# File 'lib/r_kit/core/loader.rb', line 58 def extname File.extname(file) end |
#fullpath ⇒ Object
62 63 64 65 |
# File 'lib/r_kit/core/loader.rb', line 62 def fullpath file.chomp! File.extname(file) File.(path, file) end |
#load! ⇒ Object
78 79 80 |
# File 'lib/r_kit/core/loader.rb', line 78 def load! load_path! if should_load? end |
#load_path! ⇒ Object
74 75 76 |
# File 'lib/r_kit/core/loader.rb', line 74 def load_path! require fullpath end |
#should_load? ⇒ Boolean
68 69 70 71 72 |
# File 'lib/r_kit/core/loader.rb', line 68 def should_load? conditions.inject(true) do |should_load, (statement, condition)| should_load && exec_condition(statement, condition) end end |