<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>drawohara - Latest Comments in [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.disqus.com/</link><description>drawohara rocks</description><atom:link href="https://drawohara.disqus.com/ruby_temporary_methods_for_dsls_in_ruby_aka_how_to_unextend/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 11 Sep 2008 14:08:05 -0000</lastBuildDate><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2289110</link><description>&lt;p&gt;Yes, the code is great. I especially liked your idea of using a lambda for (re)defining the methods in the helper module.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pit Capitain</dc:creator><pubDate>Thu, 11 Sep 2008 14:08:05 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2285695</link><description>&lt;p&gt;fixes applied here&lt;/p&gt;&lt;p&gt;  &lt;a href="http://s3.amazonaws.com/drawohara.com.snippets/temporary_methods_for_dsls_in_ruby_v2_rb.html" rel="nofollow noopener" target="_blank" title="http://s3.amazonaws.com/drawohara.com.snippets/temporary_methods_for_dsls_in_ruby_v2_rb.html"&gt;http://s3.amazonaws.com/dra...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drawohara</dc:creator><pubDate>Thu, 11 Sep 2008 11:47:41 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2285576</link><description>&lt;p&gt;You can say that again!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drawohara</dc:creator><pubDate>Thu, 11 Sep 2008 11:39:43 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2285575</link><description>&lt;p&gt;hey pit - nice to see you around here ;-)&lt;/p&gt;&lt;p&gt;re&lt;/p&gt;&lt;p&gt;1 - great fix.  it also fixes an issue this code had - that of forever littering the singleton class with module methods.&lt;/p&gt;&lt;p&gt;2 - yup.  good call.&lt;/p&gt;&lt;p&gt;i'm very happy with the approach thus far though - it's vastly simply than any approach i've found thus far for rapidly building intuitive and dsls.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drawohara</dc:creator><pubDate>Thu, 11 Sep 2008 11:39:32 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2282077</link><description>&lt;p&gt;Sorry for the indentation. Glad we aren't using Python :-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pit Capitain</dc:creator><pubDate>Thu, 11 Sep 2008 05:13:49 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2282073</link><description>&lt;p&gt;Nice code as always, Ara.&lt;/p&gt;&lt;p&gt;Just two remarks:&lt;/p&gt;&lt;p&gt;By using an instance variable in Methods.for it looks like you wanted to create the anonymous module only once, but you create a new one every time (actually two modules, but that's only a typo I suppose). If you want to create the module only once, you could change the code as follows:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;    def Methods.new&lt;br&gt;      Module.new do&lt;br&gt;        def self.remove!&lt;br&gt;          instance_methods.each{|m| remove_method m}&lt;br&gt;        end&lt;br&gt;      end&lt;br&gt;    end&lt;br&gt;&lt;br&gt;    def Methods.for object&lt;br&gt;      singleton_class_for(object) do&lt;br&gt;        unless defined? @dsl_methods&lt;br&gt;          @dsl_methods = Methods.new&lt;br&gt;          include @dsl_methods&lt;br&gt;        end&lt;br&gt;        @dsl_methods.module_eval(&amp;amp;Methods)&lt;br&gt;        @dsl_methods&lt;br&gt;      end&lt;br&gt;    end&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The second remark: you don't need instance_eval and the block parameter in the #dsl method, because you already call it in the scope of self. So all you need is a yield.&lt;/p&gt;&lt;p&gt;Regards,&lt;br&gt;Pit&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pit Capitain</dc:creator><pubDate>Thu, 11 Sep 2008 05:12:21 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2188495</link><description>&lt;p&gt;in that case, next time i'm in boulder i'm buying you some beer!  that is the least i owe you.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Michael Guterl</dc:creator><pubDate>Sat, 06 Sep 2008 17:09:54 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2186676</link><description>&lt;p&gt;it's quite simple really -- coffee and beer go in: code comes out.  ;-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drawohara</dc:creator><pubDate>Sat, 06 Sep 2008 13:52:15 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2186673</link><description>&lt;p&gt;i'm psyched to play with it -- been trying to figure how to do something like that for a long time!  ;-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drawohara</dc:creator><pubDate>Sat, 06 Sep 2008 13:51:44 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2141625</link><description>&lt;p&gt;you should write how your brain works!&lt;br&gt;or simpler, how to become a better rubyist.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">s</dc:creator><pubDate>Fri, 05 Sep 2008 07:13:49 -0000</pubDate></item><item><title>Re: [Ruby] temporary methods for dsls in ruby, aka - how to unextend</title><link>http://drawohara.com/post/48758159#comment-2138806</link><description>&lt;p&gt;This is really interesting.  Your ruby-fu never ceases to amaze me.&lt;/p&gt;&lt;p&gt;Thanks for all that you contribute to the ruby community!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Michael Guterl</dc:creator><pubDate>Fri, 05 Sep 2008 00:11:34 -0000</pubDate></item></channel></rss>