Project

nanoboy

0.0
No commit activity in last 3 years
No release in over 3 years
Lazy extend ruby classes and modules
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10.0
 Project Readme

Nanoboy

nanoboy is a little ruby gem that allows you to extend classes and/or modules with several advantages over the usual ruby include/extend:

  • lazy extension -- the extended class is not loaded if it's not already in the memory. The extension will be applied once the class is loaded.
  • persistent on class reloading -- if you are developing in Rails, where classes are reloaded on each request, use nanoboy and forget about reloading problems and callbacks.

Due to the lazy extension feature, this gem is specially useful when you have loading order problems. For example, if you are extending a lib that is extending another lib. Yes, these things happen.

Syntax

There are two possible syntaxes:

  • Explicit
Nanoboy.include! :ClassToExtend, MyAwesomeModule
  • Sugared
:ClassToExtend.include! MyAwesomeModule

Note that the class to be extended is named with its symbol, not the constant. If you use the constant, it gets loaded and you lose.

And yes it works with namespaces too:

:"CrazyModule::ClassToExtend".include! MyAwesomeModule

About the name

As @jondeandres said, if there is a well-known gem called FactoryGirl, what's the problem with Nanoboy?