<?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>Tender Lovemaking &#187; objectgraph</title>
	<atom:link href="http://tenderlovemaking.com/category/objectgraph/feed/" rel="self" type="application/rss+xml" />
	<link>http://tenderlovemaking.com</link>
	<description>The act of making love, tenderly.</description>
	<lastBuildDate>Sun, 15 Jan 2012 04:36:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Graphing Ruby Objects</title>
		<link>http://tenderlovemaking.com/2007/06/17/graphing-ruby-objects/</link>
		<comments>http://tenderlovemaking.com/2007/06/17/graphing-ruby-objects/#comments</comments>
		<pubDate>Sun, 17 Jun 2007 18:36:05 +0000</pubDate>
		<dc:creator>Aaron Patterson</dc:creator>
				<category><![CDATA[computadora]]></category>
		<category><![CDATA[objectgraph]]></category>

		<guid isPermaLink="false">http://tenderlovemaking.com/2007/06/17/graphing-ruby-objects/</guid>
		<description><![CDATA[I&#8217;ve been working more on my ObjectGraph project, and I think I&#8217;m about ready to release. With a bunch of help from Ryan, and other Seattle.rb folks fixing my dumb errors, I&#8217;ve added a couple new features to Object Graph that I think people will enjoy. First, you can no graph ascendants of your object. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working more on my <a href="http://seattlerb.rubyforge.org/ograph/">ObjectGraph</a> project, and I think I&#8217;m about ready to release.  With a bunch of help from <a href="http://blog.zenspider.com/">Ryan</a>, and other <a href="http://seattlerb.org/">Seattle.rb</a> folks fixing my dumb errors, I&#8217;ve added a couple new features to Object Graph that I think people will enjoy.</p>
<p>First, you can no graph ascendants of your object.  Say you have a reference, and you want to know the graph pointing to that reference.  You can do it now:</p>
<pre class="brush: ruby; title: ; notranslate">
class A; end
a = A.new
struct = { <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> ne =&gt; [], :two =&gt; [a] }

grapher = ObjectGraph.new(:ascendants =&gt; true)
grapher.graph(a)
puts grapher
</pre>
<p>Which will produce this graph:<br />
<a href="http://www.flickr.com/photos/aaronp/560865450/" title="Photo Sharing"><img src="http://farm2.static.flickr.com/1182/560865450_505bfeeae4.jpg" width="370" height="172" alt="ascendants" /></a></p>
<p>You can also see differences in graphs.  Say you want to know what happens to your graph after performing some action.  Just pass a block to the graph method, and ObjectGraph will diff the two trees.  Green boxes are new objects, pink boxes are one that went away, and red arrows are references that were destroyed.</p>
<pre class="brush: ruby; title: ; notranslate">
class A; end
struct = { <img src='http://tenderlovemaking.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> ne =&gt; [], :two =&gt; [A.new]}

grapher = ObjectGraph.new
grapher.graph(struct) do |s|
  s[:one] &lt;&lt; A.new
  s[:two].pop
end
puts grapher
</pre>
<p><a href="http://www.flickr.com/photos/aaronp/560865466/" title="Photo Sharing"><img src="http://farm2.static.flickr.com/1087/560865466_d4b3ae4d05.jpg" width="370" height="159" alt="diff" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://tenderlovemaking.com/2007/06/17/graphing-ruby-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

