Module: Kernel

Defined in:
lib/autoload.rb

Instance Method Summary collapse

Instance Method Details

#autoload(cname, path) ⇒ String

Instance level autoload method.

Note: I am not so certain the instance level method is a good idea. The end used can just as easily and more cleary use ‘self.class.autoload` to do it themselves. Nonetheless, Ruby supported this so we will too.

Parameters:

  • cname (#to_sym)

    The constants name.

  • path (String)

    File path to require.

Returns:

  • (String)

    The $AUTOLOAD table.



35
36
37
# File 'lib/autoload.rb', line 35

def autoload(cname, path)
  $AUTOLOAD[[self.class, cname.to_sym]] << path
end