Module: AutoloadMethodExtension

Included in:
CAStack, CArray
Defined in:
lib/carray/autoload_method_extension.rb

Overview

Mixin that adds a small autoload_method DSL to a class:

class Foo extend AutoloadMethodExtension autoload_method "self.bar", "libfoo" # singleton method stub autoload_method "baz", "libfoo" # instance method stub end

Each stub requires library on first call; after the require, the real definition (which the library must install) replaces the stub and the original call is forwarded.

Defined at the top level instead of nested under CArray so companion gems can extend their own classes with the same DSL. Module-wide monkey patching is avoided -- only classes that explicitly extend AutoloadMethodExtension gain the method.