--0016364c716bd07a400461162330 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit > > > It would be used like: > > class Bar > def foo > 1 > end > > chain do > def foo > super + 1 > end > end > end > Just throwing this out [and I realize it's already been discussed a bit]... It seems possible as long as you start with a module always... class Class def chainable &block m odule.new m.module_eval &block include m end end class A chainable do def abc print "in original abc" end end chainable do def abc print "in second abc" super end end end >> A.new.abc in second abcin original abc I will admit the inability to share a method from one class to another [unrelated class] is surprising. It seems that it is possible to move methods from module to module and from module to class but not from class to module or class to class. Odd but not the end of the world. I suppose for a more aggressive approach you could incorporate object2module <tongue in cheek> [1]. Take care. - [1] http://banisterfiend.wordpress.com/2008/12/18/object2module-converting-ruby-objects-to-modules/ --0016364c716bd07a400461162330 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class="gmail_quote"> <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"> <div> <div> <div> <div><br></div> <div>It would be used like:</div> <div><br></div> <div> <div>class Bar</div> <div> def foo</div> <div> 1</div> <div> end</div> <div> </div> <div> chain do</div> <div> def foo</div> <div> super + 1</div> <div> end</div> <div> end</div> <div>end</div></div></div></div></div></blockquote> <div> </div> <div>Just throwing this out [and I realize it's already been discussed a bit]...</div> <div>It seems possible as long as you start with a module always...</div> <div> </div> <div>class Class<br> def chainable &block<br> m = Module.new<br> m.module_eval &block<br> include m<br> end<br>end</div> <div><br>class A<br></div> <div> chainable do<br> def abc<br> rint "in original abc"<br> end<br> end</div> <div> </div> <div> chainable do<br> def abc<br> print "in second abc"<br> super<br> end<br> end</div> <div> </div> <div>end</div> <div> </div> <div>>> A.new.abc<br>in second abcin original abc</div> <div> </div> <div> </div> <div>I will admit the inability to share a method from one class to anotherunrelated class] is surprising. It seems that it is possible to move methods from module to module and from module to class but not from class to module or class to class. Odd but not the end of the world.</div> <div> </div> <div>I suppose for a more aggressive approach you could incorporate object2module <tongue in cheek> [1].</div> <div> </div> <div>Take care.</div> <div> </div> <div>-=r</div> <div> </div> <div>[1] http://banisterfiend.wordpress.com/2008/12/18/object2module-converting-ruby-objects-to-modules/</div> </div> --0016364c716bd07a400461162330--