Method: Autoloaded::Autoloader#with
- Defined in:
- lib/autoloaded/autoloader.rb
#with(*arguments) ⇒ Autoloader
Specifies constants and/or source files to be autoloaded whose names may have unpredictable spellings, stylization, or organization. Symbol arguments signify the names of constants and String arguments signify the names of source files. You can specify #with multiple times, and its effects are cumulative.
Source file names specified are relative to #from.
Valid arguments include:
-
Symbol values
-
Array values comprising Symbol values
-
Hash values comprising Symbol, String, and/or Array values described above, which will autoload specified constants from their associated source files
-
Any combination of the options described above
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/autoloaded/autoloader.rb', line 180 [:except, :only, :with].each do |attr| define_method attr do |*arguments| attr_specs = specifications.send(attr) if arguments.empty? return attr_specs.collect(&:value) end attr_specs << Specification.new(*arguments) begin specifications.validate! attr rescue attr_specs.pop raise end self end end |