Module | PromoteSelf |
In: |
lib/facets/more/promoteself.rb
|
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 wishing to offer both an inheritable and a module callable procedure.
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'
singleton_method_added | -> | singleton_method_added_promoteself |