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
some_value
end
end
end
class SecondClass
include ClosureExpose.capture
end
# the result
obj = SecondClass.new
obj.local_value.should == 'some class level value'
|
Or at the simple object level:
Thing = Object.new
Thang = Object.new
injector :agent
Thing.extend agent
Thang.extend agent
agent do # on the fly definitions
def capability
'do the deed'
end
def location
'main building'
end
end
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, ...
read on
Please feel free to use it free of charge and to send us your comments or inquiries. Available from RubyGems.org for Linux, Mac, and Windows. Just run: gem install jackbox.
More info here:
https://github.com/LouHenryAlvarez/jackbox
Thank you.
No comments:
Post a Comment