redding/deas — pull request #78 by kellyredding (2013-05-31 22:23:49+00:00)
Title: plugin mixin for defining formal plugin mixin modules

Use this mixin to define formal Deas plugins. Plugins are modules
that can be included onto your view handlers to extend their
behavior. Plugins can be useful for adding methods to the receivers
API or adding in callbacks on behalf of the receiver.

All of this can be accomplished using typical Ruby modules. However,
if a `self.included` hook is used to do the actions, they may be
run many times (each time something includes your module).

Not all actions are safe to call multiple times. Added handler callbacks,
for example, should only be done once. If you normal modules with
`self.included` hooks, you cannot guarantee those included hooks will
only run once.

This is where Deas plugins can help. Mixin `Deas::Plugin` into your
plugin modules. Then define as many `plugin_included` hooks as you
like. When the module is included on a receiver, Deas::Plugin makes
sure each hook is class eval'd on the receiver and that it is only
eval'd once - no matter how many times the module is included (even
if a 3rd-party includes it on behalf of the receiver).

@jcredding ready for review.