<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dr Nic &#187; BTS</title>
	<atom:link href="http://drnicwilliams.com/category/bts/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<lastBuildDate>Tue, 03 Aug 2010 23:44:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Meta-Magic in Ruby: Dr Nic Unplugged in Stockholm</title>
		<link>http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/</link>
		<comments>http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 05:52:35 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[Magic Models]]></category>
		<category><![CDATA[Magic Wiggly Lines]]></category>
		<category><![CDATA[Meta-Programming]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Trick]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/</guid>
		<description><![CDATA[Last nights&#8217; Ruby meeting in Stockholm had a great turn out and starred Ola Bini sharing the latest and greatest about JRuby, and myself giving an overview on the wonders of Meta-Magic in Ruby. I&#8217;ll write a separate post on Ola&#8217;s presentation shortly. It was awesome and I videoed it. Hehehe. But first and foremost, [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Last nights&#8217; Ruby meeting in <a href="http://www.rails.se/rails/show/Railstr%C3%A4ff+20+Mars+2007">Stockholm</a> had a great turn out and starred <a href="http://ola-bini.blogspot.com/">Ola Bini</a> sharing the latest and greatest about <a href="http://jruby.codehaus.org/">JRuby</a>, and myself giving an overview on the wonders of Meta-Magic in Ruby.</p>
<p>I&#8217;ll write a separate post on Ola&#8217;s presentation shortly. It was awesome and I videoed it. <em>Hehehe.</em></p>
<div>
But first and foremost, lets talk about me. Or rather, let&#8217;s talk about my talk, which was also videoed.</p>
<div style="float: right" >
<a id="p157" href="http://drnicwilliams.com/wp-content/uploads/2007/03/meta-magic-in-ruby-stockholm-2007-03-20.pdf" title="Meta-magic in Ruby - Weaponry"><img id="image159" src="http://drnicwilliams.com/wp-content/uploads/2007/03/pdf-file.thumbnail.jpg" alt="PDF File" /><br />Meta-magic in Ruby<br />- Weaponry.pdf</a></div>
<p>Meta-magic in a programming language is as important to programmers as changeable ring tones are to teenagers. Authors of programming languages cannot provide every feature to everyone, so it is so wonderful to be able to add new language features and extensions that you want. Everyone knows you can add Jessica Simpson as your mobile ring tone, but not all programmers know that you can add new features to their programming world. </p>
<p>So here is an overview to a new world of happiness. It also overviews how the <a href="http://magicmodels.rubyforge.org">Magic Models</a> work, and introduces a new gem I&#8217;m working on &#8211; the <strong>Magic Wiggly Lines</strong> &#8211; described as &#8220;<a href="http://ola-bini.blogspot.com/2007/03/post-rails-meetup.html">genius or insane</a>&#8221;</p>
</div>
<p><embed style="width:500px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-8652861546168277758&#038;hl=en" flashvars=""> </embed></p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Turn-based game DSL</title>
		<link>http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/</link>
		<comments>http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/#comments</comments>
		<pubDate>Thu, 07 Sep 2006 09:28:17 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/</guid>
		<description><![CDATA[Late in the night, whilst the baby feeds, I continue to develop Dr Nic&#8217;s Civilizations game. This led me to develop a DSL for the specification of game rules. You need to see this. Here&#8217;s an example definition of some terrain: class Desert < Terrain title "Desert" letter "d" graphic "desert" movement_cost 1 defense_bonus 10 [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/11/20/coming-home-to-brisbane/' rel='bookmark' title='Permanent Link: Coming home to Brisbane'>Coming home to Brisbane</a> <small>I left Australia on the 3rd of July last year...</small></li><li><a href='http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/' rel='bookmark' title='Permanent Link: Extending _why&#8217;s Creature class'>Extending _why&#8217;s Creature class</a> <small>Many Rubist&#8217;s first explanation of metaprogramming is by why the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Late in the night, whilst the baby feeds, I continue to develop <strong>Dr Nic&#8217;s Civilizations</strong> game. This led me to develop a DSL for the specification of game rules. You need to see this.</p>
<p>Here&#8217;s an example definition of some terrain:</p>
<pre>
  class Desert < Terrain
    title           "Desert"
    letter          "d"
    graphic         "desert"
    movement_cost   1
    defense_bonus   10
    food            0
    shield          1
    trade           0
  end
  class Oasis < Desert
    title           "Oasis"
    special_code    1
    food            3
    shield          1
    trade           0
    graphic         "oasis"
  end
</pre>
<p>An Oasis is a special version of the Desert terrain, so Ruby subclasses offer a compatible relationship.</p>
<p>This is seriously cool. All in Ruby.</p>
<h3>Why write a DSL for something trite like game rules?</h3>
<p>The descriptions of terrain (plains, hills, ocean), the improvements (roads, irrigation, mines), etc. all need defining somewhere. Here are the standard options:</p>
<ol>
<li>Rows in a database, imported into ActiveRecords at startup</li>
<li>Files that are loaded at startup, parsed and converted into an internal data model</li>
<li>Ruby DSL</li>
</ol>
<p>The sort of configuration we're dealing with is static: its a part of the game design to a certain extent. Yes, I could put the configuration in a database and access/modify it via an <a href="http://trac.visualjquery.com/admin_console">admin console</a>, though version control becomes an additional administrative hassle.</p>
<p>Storing game rule configuration in external files makes version control trivial, though there is a one-time cost of implementing special purpose syntax, parsers, internal game data models and testing.</p>
<p>A Ruby DSL is exactly the same as implementing option 2 - the configuration is stored in files, though as the syntax is pure Ruby, there is no need to implement a parser and internal data model. </p>
<p>There was a one time cost for supporting the syntax. But <a href="http://redhanded.hobix.com/">why the lucky stiff</a> paid this cost for me with his <a href="http://poignantguide.net/ruby/chapter-6.html#section3">traits definition for slaying dragons</a> <a href="#game-dsl1">[1]</a>. So I was free and clear of any actual effort.</p>
<h3>"Yes, smart arse, but you still had to write up all those Ruby classes"</h3>
<p>An irrelevant argument, you'd have to enter the configuration for any of the 3 options, but...</p>
<p>I wrote a generator to build the Ruby class definitions for me from the <a href="http://www.freeciv.org/index.php">Freeciv</a>'s GPL rule sets. Sweet.</p>
<p><a name="game-dsl1">[1]</a> The definition of the <code>Terrain</code> class, using the <code>traits</code> mechanism, is simple:</p>
<pre>
  class <span class="constant">Terrain</span>
    <span class="string">traits</span> :title,
      :letter,
      :graphic,
      :movement_cost,
      :defense_bonus,
      :food,
      :shield,
      :trade,
      :special_code
  end
</pre>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/11/20/coming-home-to-brisbane/' rel='bookmark' title='Permanent Link: Coming home to Brisbane'>Coming home to Brisbane</a> <small>I left Australia on the 3rd of July last year...</small></li><li><a href='http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/' rel='bookmark' title='Permanent Link: Extending _why&#8217;s Creature class'>Extending _why&#8217;s Creature class</a> <small>Many Rubist&#8217;s first explanation of metaprogramming is by why the...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Translation of RSS feeds a failure (part 3)</title>
		<link>http://drnicwilliams.com/2006/08/30/translation-of-rss-feeds-a-failure/</link>
		<comments>http://drnicwilliams.com/2006/08/30/translation-of-rss-feeds-a-failure/#comments</comments>
		<pubDate>Wed, 30 Aug 2006 12:11:19 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Translation]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/30/translation-of-rss-feeds-a-failure/</guid>
		<description><![CDATA[My path to spying on the Japanese wouldn&#8217;t be complete without support for translating RSS feeds. The translation needs to be performed on the feed itself before it hits the feedreader (unless you have non-Ajaxy webreaders that you can translate). Unfortunately, Google Translate seems to ignore RSS altogether, and just redirects you back to the [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2006/09/01/fixing-your-feedburner-feeds/' rel='bookmark' title='Permanent Link: Fixing your Feedburner feeds'>Fixing your Feedburner feeds</a> <small>Feedburner is great &#8211; you get snazzy graphs [1]. And...</small></li><li><a href='http://drnicwilliams.com/2006/08/30/foreign-tourists-to-your-websites-part-2/' rel='bookmark' title='Permanent Link: Foreign tourists to your websites (part 2)'>Foreign tourists to your websites (part 2)</a> <small>As a follow-up to the recent &#8220;Spy on the Japanese&#8221;...</small></li><li><a href='http://drnicwilliams.com/2006/08/29/ann-spy-on-the-japanese-rubists/' rel='bookmark' title='Permanent Link: [ANN] Spy on the Japanese Rubists'>[ANN] Spy on the Japanese Rubists</a> <small>Their Ruby code is surrounded by a shrouded of Japanese...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>My path to spying on the Japanese wouldn&#8217;t be complete without support for translating RSS feeds. The translation needs to be performed on the feed itself before it hits the feedreader (unless you have non-Ajaxy webreaders that you can translate).</p>
<p>Unfortunately, Google Translate seems to ignore RSS altogether, and just redirects you back to the original RSS feed.</p>
<p>For example, take sample feed: <a href="http://d.hatena.ne.jp/hanazukin/rss2">http://d.hatena.ne.jp/hanazukin/rss2</a></p>
<p>Press the Spy on Japanese bookmarklet (cheat: <a href="http://translate.google.com/translate?langpair=ja&#038;en&#038;hl=en&#038;ie=UTF-8&#038;oe=UTF-8&#038;u=http%3A%2F%2Fd.hatena.ne.jp%2Fhanazukin%2Frss2">click here for translation</a>) and you&#8217;ll see the original RSS feed in the lower frame. Its not that its been poorly translated &#8211; Google just redirects you back to the original page instead of translating it.</p>
<p>Two solutions:</p>
<ol>
<li>Use a HTML -> RSS feed converter and use the direct translation url (use translate_c? instead of translate? in the url)</li>
<li>Google Translate should add RSS feed translation. Really it cannot be more difficult than HTML translation. Add some caching (which google loves to do anyway) so its not translating each time my feed reader polls the feed, and you&#8217;re off and running.</li>
<li><strong>NEW</strong> &#8211; create a translator proxy that accepts RSS feed urls, converts the feed to a primitive HTML format, translate on google, convert results back to RSS feed
</ol>
<p>I prefer #2. So, if any Googlers read this blog, or if any friends of Larry &#038; Co. are reading this blog, or if anyone remotely interested in popping over to the Googleplex to pass on a message from me, could ask the Google Translate ppl to add RSS feed support, I&#8217;d be a very very happy man.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2006/09/01/fixing-your-feedburner-feeds/' rel='bookmark' title='Permanent Link: Fixing your Feedburner feeds'>Fixing your Feedburner feeds</a> <small>Feedburner is great &#8211; you get snazzy graphs [1]. And...</small></li><li><a href='http://drnicwilliams.com/2006/08/30/foreign-tourists-to-your-websites-part-2/' rel='bookmark' title='Permanent Link: Foreign tourists to your websites (part 2)'>Foreign tourists to your websites (part 2)</a> <small>As a follow-up to the recent &#8220;Spy on the Japanese&#8221;...</small></li><li><a href='http://drnicwilliams.com/2006/08/29/ann-spy-on-the-japanese-rubists/' rel='bookmark' title='Permanent Link: [ANN] Spy on the Japanese Rubists'>[ANN] Spy on the Japanese Rubists</a> <small>Their Ruby code is surrounded by a shrouded of Japanese...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/30/translation-of-rss-feeds-a-failure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending _why&#8217;s Creature class</title>
		<link>http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/</link>
		<comments>http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/#comments</comments>
		<pubDate>Mon, 28 Aug 2006 21:06:40 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[Meta-Programming]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/</guid>
		<description><![CDATA[Many Rubist&#8217;s first explanation of metaprogramming is by why the lucky stiff (_why)&#8217;s Why&#8217;s (Poignant) Guide to Ruby, chapter 6, section 3. You go on a dragon-hunting, adventure game using sexy Ruby syntax (a domain-specific language/DSL for adventure games?). Here is some sample syntax for defining a monster class: class Dragon < Creature life 1340 [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/10/03/extending-rails-is-like-converting-a-mini-cooper-into-a-rocket-car/' rel='bookmark' title='Permanent Link: Extending Rails is like converting a Mini Cooper into a Rocket Car'>Extending Rails is like converting a Mini Cooper into a Rocket Car</a> <small>Not only is Ruby on Rails open sourced so all...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Many Rubist&#8217;s first explanation of metaprogramming is by <a href="http://redhanded.hobix.com/">why the lucky stiff</a> (_why)&#8217;s <a href="http://poignantguide.net/ruby/index.html">Why&#8217;s (Poignant) Guide to Ruby</a>, chapter 6, <a href="http://poignantguide.net/ruby/chapter-6.html#section3">section 3</a>.</p>
<p>You go on a dragon-hunting, adventure game using sexy Ruby syntax (a domain-specific language/DSL for adventure games?). Here is some sample syntax for defining a monster class:</p>
<pre>
 class Dragon < Creature
   life 1340     # tough scales
   strength 451  # bristling veins
   charisma 1020 # toothy smile
   weapon 939    # fire breath
 end
</pre>
<p>The <code>life</code>, <code>strength</code>, <code>charisma</code> and <code>weapon</code> class methods are generated by a <code>traits</code> class method called against the <code>Creature</code> class (read the chapter). </p>
<pre>
class Creature
  traits :life, :strength, :charisma, :weapon
end
</pre>
<p>Read this chapter section many times and admire the beauty of the idea (and amuse yourself with his writing style!).</p>
<p>But there is one small improvement that could be made: currently, after setting the trait methods (e.g. <code>life 1340</code> sets the life trait to 1340), you cannot access the class's trait values directly via their original trait method. That is, you cannot call <code>Dragon.life</code> to retrieve the value 1340.</p>
<p>This is due to a limitation of the <code>define_method</code> method being used. The relevant code from _why's book is:</p>
<pre>
   def self.traits( *arr )
     # 2. Add a new class method to for each trait.
     arr.each do |a|
       metaclass.instance_eval do
         <span class="constant">define_method( a ) do |val|</span>
           @traits ||= {}
           @traits[a] = val
         end
       end
     end
</pre>
<p>The method creator <code>define_method</code> uses a <a href="http://www.rubycentral.com/book/tut_containers.html">block</a> to define the generated method body. The parameters for the block (<code>val</code> in the example above) become the arguments of the method once its been added to the class. That is, if we call <code>traits :life</code> on our Creature class, then a class method will be generated that requires one argument - the value of the trait. That is, it will generate the following method:</p>
<pre>
class Creature
  def life(val)
    @traits ||= {}
    @traits[:life] = val
  end
end
</pre>
<p>Now, back to the problem. How do we support the syntax <code>Dragon.life</code>? To achieve this, the generated method would need to look like:</p>
<pre>
class Creature
  def life(<span class="constant">val = nil</span>)
    @traits ||= {}
    <span class="constant">return @traits[:life] if not val</span>
    @traits[:life] = val
  end
end
</pre>
<p>That is, we need a default value for our method argument. But... blocks don't allow parameters to have default values. We cannot do the following:</p>
<pre>
         define_method( a ) do |<span class="constant">val = nil</span>|
           @traits ||= {}
           return @traits[a] if not val
           @traits[a] = val
         end
</pre>
<p>A pity, yes.</p>
<p>So, we need to generate our methods differently. The solution is as follows:</p>
<pre>
      metaclass.class_eval <<-EOS
        def #{a}(val=nil)
          @traits ||= {}
          return @traits[:#{a}] if not val
          @traits[:#{a}] = val
        end
      EOS
</pre>
<p>The <code>eval</code> methods allow a string to be passed to them. So, we shall pass it a string that defines a new method the old fashioned way: using the <code>def</code> method constructor. Thus it allows us to have default values for our arguments. </p>
<p><a href="http://en.wikipedia.org/wiki/Q.E.D.">QED</a>.</p>
<p>ALTERNATIVE from Chris @ <a href="http://errthblog.com">Errtheblog.com</a></p>
<p>Use the splat! (*) to allow zero or more arguments. Pluck the first one off to represent the incoming argument or nil.</p>
<pre>
def self.traits( *arr )
  arr.each do |a|
    metaclass.instance_eval do
       define_method( a ) do |<span class="constant">*val</span>|
         <span class="constant">val = val.first</span>
         @traits ||= {}
         return @traits[a] if not val
         @traits[a] = val
       end
     end
  end
end
</pre>
<p>There are unanswered questions about its support for 2+ arguments (where we only need support for 0 or 1) that shall remain unanswered for the sake of this simple hack. But feel free to start throwing exceptions around if your users need protection from themselves.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/10/03/extending-rails-is-like-converting-a-mini-cooper-into-a-rocket-car/' rel='bookmark' title='Permanent Link: Extending Rails is like converting a Mini Cooper into a Rocket Car'>Extending Rails is like converting a Mini Cooper into a Rocket Car</a> <small>Not only is Ruby on Rails open sourced so all...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>So, cattr_accessor doesn&#8217;t work like it should?</title>
		<link>http://drnicwilliams.com/2006/08/27/so-cattr_accessor-doesnt-work-like-it-should/</link>
		<comments>http://drnicwilliams.com/2006/08/27/so-cattr_accessor-doesnt-work-like-it-should/#comments</comments>
		<pubDate>Sun, 27 Aug 2006 15:59:20 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[Meta-Programming]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/27/so-cattr_accessor-doesnt-work-like-it-should/</guid>
		<description><![CDATA[Rails&#8217; active_support library adds some wonderful functions into standard Ruby classes. Some we all use day-in-day out are attr_accessor and its class-level equivalent, cattr_accessor. But cattr_accessor doesn&#8217;t work the way you (read, &#8220;me&#8221;) thought at first glance when you use subclasses. I thought if I declared a class accessor in the superclass, then I would [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/' rel='bookmark' title='Permanent Link: Turn-based game DSL'>Turn-based game DSL</a> <small>Late in the night, whilst the baby feeds, I continue...</small></li><li><a href='http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/' rel='bookmark' title='Permanent Link: Extending _why&#8217;s Creature class'>Extending _why&#8217;s Creature class</a> <small>Many Rubist&#8217;s first explanation of metaprogramming is by why the...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Rails&#8217; <code>active_support</code> library adds some wonderful functions into standard Ruby classes. Some we all use day-in-day out are <code>attr_accessor</code> and its class-level equivalent, <code>cattr_accessor</code>.</p>
<p>But <code>cattr_accessor</code> doesn&#8217;t work the way you (read, &#8220;me&#8221;) thought at first glance when you use subclasses. I thought if I declared a class accessor in the superclass, then I would have independent class attributes for all my subclasses. Apparently not&#8230;</p>
<pre>
>> class Parent; <strong>cattr_accessor</strong> :val; end
=> [:val]
>> class Child1 < Parent; end
=> nil
>> class Child2 < Parent; end
=> nil
>> Child1.val = 4
=> 4
>> Child2.val
=> 4
>> Child2.val = 5
=> 5
>> Child1.val
=> 5
</pre>
<p><code>Child1.val</code> and <code>Child2.val</code> seem to be the same value. Not very independent at all. Internally, the classes share a common class attribute. This is useful in certain circumstances, but not what I was looking for.</p>
<p>Instead, I found <code>class_inheritable_accessor</code>.</p>
<pre>
>> class Parent; <strong>class_inheritable_accessor</strong> :val; end
=> [:val]
>> class Child1 < Parent; end
=> nil
>> class Child2 < Parent; end
=> nil
>> Child1.val = 4
=> 4
>> Child2.val = 4
=> 4
>> Child2.val = 5
=> 5
>> Child1.val
=> 4
</pre>
<p>Lovely. Each subclass will have an independent value once you&#8217;ve assigned it a value explicitly, else it will pick up the value from its superclass.</p>
<p>UPDATE: <code>class_inheritable_accessor</code> and co. actually clone the superclass&#8217;s inherited attributes, rather than just referencing them.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/04/12/magic-multi-connections-a-facility-in-rails-to-talk-to-more-than-one-database-at-a-time/' rel='bookmark' title='Permanent Link: Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;'>Magic Multi-Connections: A &#8220;facility in Rails to talk to more than one database at a time&#8221;</a> <small>At this point in time there’s no facility in Rails...</small></li><li><a href='http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/' rel='bookmark' title='Permanent Link: Turn-based game DSL'>Turn-based game DSL</a> <small>Late in the night, whilst the baby feeds, I continue...</small></li><li><a href='http://drnicwilliams.com/2006/08/28/extending-_whys-creature-class/' rel='bookmark' title='Permanent Link: Extending _why&#8217;s Creature class'>Extending _why&#8217;s Creature class</a> <small>Many Rubist&#8217;s first explanation of metaprogramming is by why the...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/27/so-cattr_accessor-doesnt-work-like-it-should/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>[BTS] Dr Nic&#8217;s Civilizations 2.0</title>
		<link>http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/</link>
		<comments>http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 22:32:43 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Preview]]></category>
		<category><![CDATA[Trick]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/</guid>
		<description><![CDATA[I&#8217;m not promising there ever will be a Dr Nic&#8217;s Online Civilizations game, but it has seemed like a good idea for a few weeks, and today I went from ASCII map through to beautiful CSS rendering of the map. 6amASCII to HTML mapping 8amBase tiles 6pmCorrect edges 9pmConvert table to div structure I miss [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/' rel='bookmark' title='Permanent Link: Turn-based game DSL'>Turn-based game DSL</a> <small>Late in the night, whilst the baby feeds, I continue...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not promising there ever will be a Dr Nic&#8217;s Online Civilizations game, but it has seemed like a good idea for a few weeks, and today I went from ASCII map through to beautiful CSS rendering of the map.</p>
<table border=0>
<tr align=center>
<th>6am<br />ASCII to HTML mapping</th>
<th>8am<br />Base tiles</th>
<th>6pm<br />Correct edges</th>
<th>9pm<br />Convert table to div structure</th>
</tr>
<tr align=center>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-01-map-to-colour-scheme.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-01-map-to-colour-scheme.thumbnail.png" alt="Simple layout of map" /></a></td>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-02-basic-tiles.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-02-basic-tiles.thumbnail.png" alt="Basic tiles" /></a></td>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-04-tile-variations-correct-edges.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-04-tile-variations-correct-edges.thumbnail.png" alt="Correct edges" /></a></td>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-06-removed-table.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-06-removed-table.thumbnail.png" alt="Removed table structure" /></a></td>
</tr>
</table>
<p>I miss home.</p>
<div><a style="float: right" href="http://drnicwilliams.com/wp-content/uploads/2006/08/tiles.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/tiles.thumbnail.png" alt="Tilesheet" /></a>This was a technically interesting process. The images used are actually all on the one base tile sheet <a href="#a1">[1]</a>, and each panel of the map is allocated a separate CSS class relating to the specific tile required.</div>
<p>So for example, to show the base grasslands tile, you&#8217;d need some CSS like:</p>
<pre>
.tiles {height: 30px; width: 30px; background: url(tiles.png) top left no-repeat; ...}
.grasslands {background-position: 0px -30px;}</pre>
<p>For a desert tile, with some grasslands to the left, you might use:</p>
<pre>
.desert-left {background-position: -60px -60px;}</pre>
<p>This really gives a nice tiling effect without you needing to do any fancy image manipulations or the user loading up lots of small images. You just assign the appropriate CSS class to the panel (a DIV or TD, for example). Want to change a tile? Change the class (e.g. using Prototype/jQuery libraries)</p>
<p>Yes, this solution requires lots of individual CSS class definitions; but you&#8217;re clever &#8211; you&#8217;ll generate them won&#8217;t you <img src='http://drnicwilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Reader assistance required</h3>
<p>The one technical trick that I don&#8217;t have a solution for at the moment is a Google Maps-like interface for scrolling map around. I&#8217;d love to hear from anyone with some bright thoughts on how they implement that (I don&#8217;t want to have to try to read their compact Javascript code).</p>
<p>Any thoughts?</p>
<p><a name="a1">[1]</a> The source images came from the <a href="http://www.freeciv.org/index.php/Freeciv">FreeCiv</a> GPL game</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/' rel='bookmark' title='Permanent Link: Turn-based game DSL'>Turn-based game DSL</a> <small>Late in the night, whilst the baby feeds, I continue...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[BTS] Magic Models vs ActiveRecords &#8211; Efficiency</title>
		<link>http://drnicwilliams.com/2006/08/22/bts-magic-models-vs-activerecords-efficiency/</link>
		<comments>http://drnicwilliams.com/2006/08/22/bts-magic-models-vs-activerecords-efficiency/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 15:11:41 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[Magic Models]]></category>
		<category><![CDATA[Meta-Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/22/bts-magic-models-vs-activerecords-efficiency/</guid>
		<description><![CDATA[Dr Nic&#8217;s Magic Models are magical, that goes without saying. But are they efficient at being magical? Do you get the same speed in your application as if you explicitly defined your classes and your associations will your application execute faster? Yes. The cost of accessing a Magic Model and a normal ActiveRecord is exactly [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/' rel='bookmark' title='Permanent Link: map_by_method now works with ActiveRecord associations'>map_by_method now works with ActiveRecord associations</a> <small>I was always annoyed that map_by_method was broken for ActiveRecord...</small></li><li><a href='http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/' rel='bookmark' title='Permanent Link: Magic Wiggly Lines => GuessMethod, by Chris Shea'>Magic Wiggly Lines => GuessMethod, by Chris Shea</a> <small>If you ever make time to code just for pleasure,...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Dr Nic&#8217;s Magic Models are magical, that goes without saying. But are they efficient at being magical? Do you get the same speed in your application as if you explicitly defined your classes and your associations will your application execute faster?</p>
<p><strong>Yes</strong>. The cost of accessing a Magic Model and a normal ActiveRecord is exactly the same &#8211; once the Magic Model has been initially generated. Its just a normal ActiveRecord like all your other ActiveRecords: they are loaded into memory when you first ask for them. Normal ActiveRecords are loaded into memory from your <code>/app/models/<model_name>.rb</code> file; Magic Models are generated classes. The Magic Models would in fact be quicker to load as there is no file access required.</p>
<p>The cost of accessing Automatic Associations versus normal Active Record associations is also exactly the same. To understand the inner workings of associations, see err.the_blog&#8217;s <a href="http://errtheblog.com/post/20">latest article</a>.</p>
<p>The point to take away from the discussion is that associations are a generated method on your class. Once you&#8217;ve generated it once (at the time you call <code>has_many</code> for example), you have it permanently. So there is only a small, one-time cost for the Automatic Associations &#8211; to see which association to generate for the incoming method call. But once you&#8217;ve generated the association, its yours permanently. </p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/08/12/magiccgi/' rel='bookmark' title='Permanent Link: MagicCGI shows OpenID user count'>MagicCGI shows OpenID user count</a> <small> In the last 20 days, 43 people have used...</small></li><li><a href='http://drnicwilliams.com/2007/08/12/map_by_method-now-works-with-activerecord-associations/' rel='bookmark' title='Permanent Link: map_by_method now works with ActiveRecord associations'>map_by_method now works with ActiveRecord associations</a> <small>I was always annoyed that map_by_method was broken for ActiveRecord...</small></li><li><a href='http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/' rel='bookmark' title='Permanent Link: Magic Wiggly Lines => GuessMethod, by Chris Shea'>Magic Wiggly Lines => GuessMethod, by Chris Shea</a> <small>If you ever make time to code just for pleasure,...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/22/bts-magic-models-vs-activerecords-efficiency/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[BTS] Magic Models &#8211; Class creation</title>
		<link>http://drnicwilliams.com/2006/08/10/bts-magic-models-class-creation/</link>
		<comments>http://drnicwilliams.com/2006/08/10/bts-magic-models-class-creation/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 13:01:39 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[Magic Models]]></category>
		<category><![CDATA[Meta-Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/10/bts-magic-models-class-creation/</guid>
		<description><![CDATA[[BTS] = Behind the Scenes; also a news-like TV show we used to watch as school kids (in Australia) that explored world news events and then our teachers would make us write reports about it. (UPDATE: this is a lie; it was BTN &#8211; Behind the News) Anyway&#8230;. Class creation &#8211; the magical way As [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2008/04/03/the-explicit-ruby-metaclass-you-know-you-always-wanted/' rel='bookmark' title='Permanent Link: The explicit Ruby metaclass you know you always wanted'>The explicit Ruby metaclass you know you always wanted</a> <small>When you define a &#8220;static&#8221; or &#8220;class&#8221; method on a...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>[BTS] = Behind the Scenes;  also a news-like TV show we used to watch as school kids (in Australia) that explored world news events and then our teachers would make us write reports about it. (UPDATE: this is a lie; it was BTN &#8211; Behind the News) Anyway&#8230;. </p>
<h3>Class creation &#8211; the magical way</h3>
<p>As an educational exercise, it is definitely interesting to look at how the Magic Model&#8217;s Invisible Classes <a href="#footer-1">[1]</a> are generated. Inside the gem <a href="#footer-2">[2]</a>, please turn to the file <code>/lib/module.rb</code> I&#8217;ve broken it up below too.</p>
<pre syntax="ruby">
class Module
  alias :normal_const_missing :const_missing

  def const_missing(class_id)
    begin; return normal_const_missing(class_id); rescue; end
</pre>
<p>If you open the Irb/Console and type <code>Foo</code>, you&#8217;ll get an &#8220;unitialized constant Foo&#8221; error. This is raised by the <code>const_missing</code> method in the <code>Module</code> class. Yes, there&#8217;s a core class called Module. Type <code>Module.methods.sort</code> to see all the fun things it can do, or look up the <a href="http://ruby-doc.org/core/classes/Module.html">API</a>.</p>
<p>Like so many things in Ruby you can override this method, just like you might override the <code>method_missing</code> on a class (Rails does this on its ActiveRecord to support the <code>find_by_...</code> magical methods.)</p>
<p>When you load Magic Models (via the <code>require 'dr_nic_magic_models'</code> statement) it renames/aliases the current const_missing method and then overrides it.</p>
<p>The first thing it does it call the original const_missing to see if it returns anything useful. Why? Rails also overrides this method. Rails doesn&#8217;t preload all your model classes at start up. Instead when you first ask for a model class, it loads it via the const_missing method call. So Magic Models won&#8217;t do anything until Rails has had a chance to try an load the class from a <code>app/models/foo.rb</code> file, for example.</p>
<pre syntax="ruby">
    unless table_name = DrNicMagicModels::Schema.models[class_id]
      raise NameError.new("uninitialized constant #{class_id}") if
                    DrNicMagicModels::Schema.models.enquired? class_id
    end
</pre>
<p>The DNMM::Schema class is in charge of mapping an unknown class name (class_id) to one of your database&#8217;s tables. To prevent nasty infinite recursion, we raise the &#8220;uninitialized constant&#8221; error if another const_missing request comes in for the same class_id.</p>
<pre syntax="ruby">
    klass = Class.new ActiveRecord::Base
    const_set class_id, klass
</pre>
<p>The Class <a href="http://ruby-doc.org/core/classes/Class.html">API</a> takes a superclass as a parameter. Here, we want our Invisible Model to be an ActiveRecord.</p>
<p>By setting the anonymous class object to a constant value, e.g. Foo, it <a href="http://ruby-doc.org/core/classes/Class.html#M002078">automatically names the class</a>. E.g. <code>klass.name == 'Foo'</code></p>
<pre syntax="ruby">
    klass.set_table_name table_name
</pre>
<p>Finally, we force the new ActiveRecord class to use the table name that DNMM::Scheme found. You just can&#8217;t trust that the class will know what its table name is. </p>
<p>If you find yourself using this sort of code, then here&#8217;s some bonus code. When you create your class, you can install some code at the same time.</p>
<pre syntax="ruby">
    klass_code = %q{def to_s; 'I''m magically generated'; end }
    klass_code = lambda {klass_code}
    klass = Class.new ActiveRecord::Base, &#038;klass_code
</pre>
<h3>Feedback</h3>
<p>Was this easy to read? Too compact/too long? Let me know below.</p>
<p>If you go on and build something magically cool after reading this, definitely let me know.</p>
<h3>Moral of the Story</h3>
<p>You can live as a programmer without ever knowing any meta-programming features of Ruby. Heck, we all did it in Java/C++/C# and never knew we needed them. A lot of powerful API features exist in Rails that you&#8217;d never be able to build in many other languages; the ActiveRecord library is a tribute to meta-programming magic.</p>
<p>UPDATE: I had previously called <code>Module</code> a module, when its a class. Fixed.</p>
<p><a name="footer-1">[1]  I just like calling them Invisible Models.</p>
<p><a name="footer-2">[2]  Gems are installed inside your Ruby installation folder. Try something like </code>....\lib\ruby\gems\1.8\gems\</code> and you'll see all your favourite gems, like <a href="http://weblog.rubyonrails.com/2006/8/9/rails-1-1-5-mandatory-security-patch-and-other-tidbits">rails-1.1.5</a>, active-record-1.14.4, etc.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2008/04/03/the-explicit-ruby-metaclass-you-know-you-always-wanted/' rel='bookmark' title='Permanent Link: The explicit Ruby metaclass you know you always wanted'>The explicit Ruby metaclass you know you always wanted</a> <small>When you define a &#8220;static&#8221; or &#8220;class&#8221; method on a...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/10/bts-magic-models-class-creation/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
