Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7067

Closures as Modules?

Newsgroups comp.lang.ruby
Date 2014-12-23 12:58 -0800
Message-ID <eef91daa-1a7b-4864-ac72-27d28bce9f92@googlegroups.com> (permalink)
Subject Closures as Modules?
From lukakike@gmail.com

Show all headers | View raw


Can anyone shed some light on this?

https://github.com/LouHenryAlvarez/jackbox

It looks like some sort of abstraction.  But I a having trouble understanding how this works.  Also the following code doesn't make any sense to me.

<pre>

Furhtermore, these decorators can be re-applied multiple times to the same receiver:

cup = Coffee.new.enrich(milk).enrich(sprinkles).enrich(sprinkles)
# or even..
cup = Coffee.new.enrich milk, sprinkles, sprinkles

cup.cost.should == 2.10
cup.should be_instance_of(Coffee)
cup.injectors.should == [:milk, :sprinkles, :sprinkles

</pre>

Isn't this sort of thing already possible already.  Can someone explain?


Thanks,

Kike

Back to comp.lang.ruby | Previous | Next | Find similar


Thread

Closures as Modules? lukakike@gmail.com - 2014-12-23 12:58 -0800

csiph-web