Rspec Screenshot

Rspec Screenshot
Copyright © 2014, 2015 LHA. All rights reserved.

Wednesday, January 14, 2015

Can Closures be Modules?

Well, Ladies and Gents we would like to introduce you to our new library called Jackbox.  It toys with the ideas of closures as modules.  In it you'll find a series of new takes on ruby that are sure to spike you interest.  With it we have come up with a solution to the decorators handicap in ruby and introduced some new constructs for code injection.

class ClosureExpose

   some_value = 'some class level value'

   injector :capture do
      define_method :local_value do


class SecondClass
   include ClosureExpose.capture

# the result
obj =
obj.local_value.should == 'some class level value'


Or at the simple object level:
Thing =
Thang =

injector :agent

Thing.extend agent
Thang.extend agent

agent do                                          # on the fly definitions
   def capability
      'do the deed'
   def location
      'main building'

Thing.capability.should == 'do the deed'
Thang.location.should == 'main building'

Jackbox Google+

The main library function at this time centers around the concept of code Injectors. To make it easier to grasp the idea behind them, these can perhaps be thought of as a form of closures which can also serve as modules. Most of all Injectors propose some additional interesting properties to the idea of a mix-in. For instance, on

Please feel free to use it free of charge and to send us your comments or inquiries.  Available from for Linux, Mac, and Windows.  Just run: gem install jackbox.

More info here:

Thank you.

No comments:

Post a Comment