PromoteSelf converts a module’s class methods into instance methods such that the first parameter is passed self at the instance level. This promotes DRY programming when wishin to offer both an inheritable and a module callable procedure.
Usage
module MyModule
extend PromoteSelf
def self.jumble( obj, arg )
obj + arg
end
end
class String
include MyModule
end
MyModule.jumble( "Try", "Me" ) #=> "TryMe"
"Try".jumble( "Me" ) #=> 'TryMe'
Authors(s)
- Thomas Sawyer
Methods
Public Instance methods
singleton_method_added( meth )
[ source ]