<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>blog about rails and other nerdy things.</description><title>@dhiemstra</title><generator>Tumblr (3.0; @dhiemstra)</generator><link>http://dannyhiemstra.com/</link><item><title>Sharing static variables through the inheritance tree in Ruby</title><description>&lt;p&gt;I&amp;#8217;ve been struggling a couple of hours with trying to declare static variables inside subclasses that can be used in the baseclass. Unfortunately ruby shares the class variables across all subclasses, this can lead into some unexpected behavior, see the following example:&lt;/p&gt;
&lt;script src="https://gist.github.com/1434728.js?file=1.rb"&gt;&lt;/script&gt;&lt;p&gt;After a lot of googling I gladly came across &lt;strong&gt;class_attribute&lt;/strong&gt;.&lt;/p&gt;
&lt;blockquote&gt;Declare a class-level attribute whose value is inheritable by subclasses.&lt;/blockquote&gt;
&lt;p&gt;And now the final result:&lt;/p&gt;
&lt;script src="https://gist.github.com/1434974.js?file=2.rb"&gt;&lt;/script&gt;&lt;p&gt;For more information and the full docs, see: &lt;a href="http://apidock.com/rails/Class/class_attribute"&gt;apidock.com/rails/Class/class_attribute&lt;/a&gt;&lt;/p&gt;</description><link>http://dannyhiemstra.com/post/13788433380</link><guid>http://dannyhiemstra.com/post/13788433380</guid><pubDate>Mon, 05 Dec 2011 20:56:00 +0100</pubDate><category>ruby</category><category>ruby on rails</category></item></channel></rss>

