Top Level Namespace
Defined Under Namespace
Modules: Enumerable, Net, Nuggets, URI Classes: Array, File, Hash, IO, Integer, Module, Numeric, Object, Proc, Range, String, Tempfile
Constant Summary collapse
- ContentType =
Just a short-cut to make the code read nicer…
::Nuggets::ContentType
Instance Method Summary collapse
-
#Nuggets(*nuggets) ⇒ Object
Load selected
nuggets
.
Instance Method Details
#Nuggets(*nuggets) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/nuggets.rb', line 41 def Nuggets(*nuggets) loaded_nuggets, load_nuggets = [], lambda { |base, *nuggets| nuggets_by_hierarchy = nuggets.last.is_a?(Hash) ? nuggets.pop : {} nuggets.each { |nugget| begin require path = File.join(base.to_s, nugget.to_s.downcase) loaded_nuggets << path rescue LoadError # if it's a directory, load anything in it $LOAD_PATH.each { |dir| if File.directory?(dir_path = File.join(dir, path)) load_nuggets[path, *Dir[File.join(dir_path, '*')].map { |file| File.basename(file, '.rb') unless file.end_with?('_mixin.rb') }.compact] break end } and raise # otherwise, re-raise end } nuggets_by_hierarchy.each { |hierarchy, nuggets| nuggets = [nuggets] if nuggets.is_a?(Hash) load_nuggets[File.join(base.to_s, hierarchy.to_s.downcase), *nuggets] } } load_nuggets['nuggets', *nuggets] loaded_nuggets end |