class LoadPath
Attributes
_base[RW]
conditions[RW]
file[RW]
path[RW]
priority[RW]
Public Class Methods
new(base, file:, path:, **options)
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 5 def initialize base, file:, path:, **options @_base = base @file = file @path = path @priority = options.fetch :priority, 1/0.0 @conditions = options.slice :if, :unless end
Public Instance Methods
exec_condition(statement, condition)
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 47 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)
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 58 def exec_statement statement, condition case statement when :if !!condition when :unless !condition end end
extname()
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 16 def extname File.extname(file) end
fullpath()
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 20 def fullpath file.chomp! File.extname(file) File.expand_path(path, file) << ".rb" end
load!()
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 42 def load! load_path! if should_load? end
load_path!()
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 32 def load_path! require fullpath rescue NameError => e warn %Q{ WARNING - An error occur during `RKit' initialization The file #{ fullpath } could not be loaded. Ruby stack says: #{ e.message }. } end
should_load?()
click to toggle source
# File lib/r_kit/core/loader/load_path.rb, line 26 def should_load? conditions.inject(true) do |should_load, (statement, condition)| should_load && exec_condition(statement, condition) end end