module Is::Loadable
- public
Public Instance Methods
find_loadable_paths(path, options, loadable)
click to toggle source
# File lib/is/loadable.rb, line 73 def find_loadable_paths(path, options, loadable) path.glob(options[:pattern]).sort.each do |each_path| loadable << [each_path, options] end path.glob("*").select(&:directory?).sort.each do |each_path| find_loadable_paths(each_path, options, loadable) end end
load(reload: false)
click to toggle source
- public
# File lib/is/loadable.rb, line 35 def load(reload: false) loadable = [] __loads__.each_pair do |definable, options| find_loadable_paths(options[:path], options, loadable) end while (loadable_path, loadable_options = loadable.shift) if reload || !loaded?(loadable_path) loadable_options[:context].load( path: loadable_path, root: loadable_options[:path], type: loadable_options[:type], strict: loadable_options[:strict], target: self ) __loaded_paths__ << loadable_path end end end
loaded?(path)
click to toggle source
# File lib/is/loadable.rb, line 69 def loaded?(path) __loaded_paths__.include?(Pathname(path)) end
loads(definable, path, pattern: "*.rb", strict: true, context: Core::Loader::Context)
click to toggle source
- public
# File lib/is/loadable.rb, line 19 def loads(definable, path, pattern: "*.rb", strict: true, context: Core::Loader::Context) unless ancestors.include?(Is::Factory) && makes?(definable) raise "cannot load unknown object `#{definable}`" end __loads__[definable.to_sym] = { type: definable, path: Pathname(path), pattern: pattern, strict: strict, context: context } end
reload()
click to toggle source
- public
# File lib/is/loadable.rb, line 59 def reload load(reload: true) end
reset()
click to toggle source
- public
# File lib/is/loadable.rb, line 65 def reset __loaded_paths__.clear end