Method: Module#autoreq
- Defined in:
- lib/y_support/core_ext/module/misc.rb
#autoreq(*symbols, descending_path: '..', ascending_path_prefix: 'lib') ⇒ Object
Further automation of soon-to-be-deprecated #autorequire.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/y_support/core_ext/module/misc.rb', line 6 def autoreq( *symbols, descending_path: '..', ascending_path_prefix: 'lib' ) require 'active_support/core_ext/string/inflections' namespace = self.name namespace_path = namespace.underscore namespace_chain = namespace.split "::" ascending_path = ascending_path_prefix + '/' + namespace_path symbols.map( &:to_s ).each { |ς| next if ς.strip.empty? camelized_ß = ς.camelize.to_sym path = './' + [ descending_path, ascending_path, ς ].join( '/' ) autoload camelized_ß, path } end |