<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Getting a class object in Ruby from a string containing that class&#8217; name</title>
	<atom:link href="http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/feed/" rel="self" type="application/rss+xml" />
	<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/</link>
	<description>a weblog by Tom Armitage</description>
	<lastBuildDate>Sun, 08 Apr 2012 09:50:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Josh Carter</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-161305</link>
		<dc:creator>Josh Carter</dc:creator>
		<pubDate>Mon, 26 Jul 2010 22:53:59 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-161305</guid>
		<description>@btower you really don&#039;t want to be eval&#039;ing strings that could come from an untrusted source, lest someone get a class name into your system like &quot;system(&#039;rm -rf /&#039;)&quot;. ;)

Thanks for the tips here. I had figured out the issue with creating classes under nested modules, but failed to realize that I could condense my several lines of code using inject (thanks @Mirage). FWIW more recent versions of Ruby have an alias &quot;reduce&quot; that I think is closer to the intent of the method than &quot;inject.&quot;</description>
		<content:encoded><![CDATA[<p>@btower you really don&#8217;t want to be eval&#8217;ing strings that could come from an untrusted source, lest someone get a class name into your system like &#8220;system(&#8216;rm -rf /&#8217;)&#8221;. ;)</p>
<p>Thanks for the tips here. I had figured out the issue with creating classes under nested modules, but failed to realize that I could condense my several lines of code using inject (thanks @Mirage). FWIW more recent versions of Ruby have an alias &#8220;reduce&#8221; that I think is closer to the intent of the method than &#8220;inject.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DSimon</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-161158</link>
		<dc:creator>DSimon</dc:creator>
		<pubDate>Fri, 11 Jun 2010 16:15:31 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-161158</guid>
		<description>This is lovely! It&#039;s especially nice because it is much more secure than eval when handling user input. I don&#039;t have to worry about some sneaky user trying to get me to load a type named &quot; exec &#039;rm -rf /&#039; &quot;.

Of course, I still have to make sure that the class name specified isn&#039;t something unexpected which would have disastrous side effects, but that&#039;s way easier than trying to somehow sanitize a call to exec; all I have to do is make sure the input class includes the base type of the classes I expect to deserialize in its ancestors.</description>
		<content:encoded><![CDATA[<p>This is lovely! It&#8217;s especially nice because it is much more secure than eval when handling user input. I don&#8217;t have to worry about some sneaky user trying to get me to load a type named &#8221; exec &#8216;rm -rf /&#8217; &#8220;.</p>
<p>Of course, I still have to make sure that the class name specified isn&#8217;t something unexpected which would have disastrous side effects, but that&#8217;s way easier than trying to somehow sanitize a call to exec; all I have to do is make sure the input class includes the base type of the classes I expect to deserialize in its ancestors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaydeep Dave</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-160467</link>
		<dc:creator>Jaydeep Dave</dc:creator>
		<pubDate>Mon, 08 Feb 2010 22:37:35 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-160467</guid>
		<description>This is the answer needed maaan....... you have no idea, what you have helped me to build.</description>
		<content:encoded><![CDATA[<p>This is the answer needed maaan&#8230;&#8230;. you have no idea, what you have helped me to build.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-159535</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Sat, 19 Dec 2009 13:47:40 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-159535</guid>
		<description>Thanks petef. Just needed that answer!</description>
		<content:encoded><![CDATA[<p>Thanks petef. Just needed that answer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: petef</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-157832</link>
		<dc:creator>petef</dc:creator>
		<pubDate>Tue, 17 Nov 2009 15:33:57 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-157832</guid>
		<description>And of course FWIW you can go the other way to define classes from Strings:

&lt;code&gt;
# Declare all the classes up front to avoid forward references
%w(Tom Dick Harry George).each do &#124;c&#124;
  Tunnel.const_set(c, Class.new)
end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>And of course FWIW you can go the other way to define classes from Strings:</p>
<p><code><br />
# Declare all the classes up front to avoid forward references<br />
%w(Tom Dick Harry George).each do |c|<br />
  Tunnel.const_set(c, Class.new)<br />
end<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew&#8217;s Blog &#187; Getting Reference to a Class with a String Class Name in Ruby</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-145217</link>
		<dc:creator>Andrew&#8217;s Blog &#187; Getting Reference to a Class with a String Class Name in Ruby</dc:creator>
		<pubDate>Sun, 26 Apr 2009 12:38:07 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-145217</guid>
		<description>[...] Getting a class object in Ruby from a string containing that class’ name, Programming Ruby [...]</description>
		<content:encoded><![CDATA[<p>[...] Getting a class object in Ruby from a string containing that class’ name, Programming Ruby [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: btower</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-131086</link>
		<dc:creator>btower</dc:creator>
		<pubDate>Sat, 03 Jan 2009 23:41:11 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-131086</guid>
		<description>What makes the non-eval version more maintainable?</description>
		<content:encoded><![CDATA[<p>What makes the non-eval version more maintainable?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael A</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-126501</link>
		<dc:creator>Michael A</dc:creator>
		<pubDate>Mon, 15 Dec 2008 19:33:43 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-126501</guid>
		<description>Well done Mirage. I&#039;ve never used inject for any real work but it makes short work of this problem.</description>
		<content:encoded><![CDATA[<p>Well done Mirage. I&#8217;ve never used inject for any real work but it makes short work of this problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xprdr</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-124482</link>
		<dc:creator>xprdr</dc:creator>
		<pubDate>Wed, 03 Dec 2008 09:59:04 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-124482</guid>
		<description>inject is not used for the purpose you are trying to accomplish here. plus there are at least two types of injects:
http://www.java2s.com/Code/Ruby/Range/Injectarange.htm

and 

http://www.java2s.com/Code/Ruby/Hash/injectwithregularexpression.htm</description>
		<content:encoded><![CDATA[<p>inject is not used for the purpose you are trying to accomplish here. plus there are at least two types of injects:<br />
<a href="http://www.java2s.com/Code/Ruby/Range/Injectarange.htm" rel="nofollow">http://www.java2s.com/Code/Ruby/Range/Injectarange.htm</a></p>
<p>and </p>
<p><a href="http://www.java2s.com/Code/Ruby/Hash/injectwithregularexpression.htm" rel="nofollow">http://www.java2s.com/Code/Ruby/Hash/injectwithregularexpression.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hoeppner</title>
		<link>http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/comment-page-1/#comment-124127</link>
		<dc:creator>Chris Hoeppner</dc:creator>
		<pubDate>Mon, 01 Dec 2008 14:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://infovore.org/archives/2006/08/02/getting-a-class-object-in-ruby-from-a-string-containing-that-classes-name/#comment-124127</guid>
		<description>Time to dig into #inject. It&#039;s a method I have not yet understood.</description>
		<content:encoded><![CDATA[<p>Time to dig into #inject. It&#8217;s a method I have not yet understood.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

