<?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: A dirty Ruby</title>
	<atom:link href="http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/</link>
	<description>The journal of Paul M. Watson</description>
	<pubDate>Thu, 20 Nov 2008 23:28:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7-beta1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Paul Watson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-15235</link>
		<dc:creator>Paul Watson</dc:creator>
		<pubDate>Thu, 11 May 2006 15:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-15235</guid>
		<description>How fantastic. I took the above code and cut it down to just this:&lt;br&gt;&lt;code&gt;if soapResponse.getNewTagsSinceResult.respond_to? "tag"&lt;br&gt;&#38;nbsp;&#38;nbsp;for tag_current in Array(soapResponse.getNewTagsSinceResult.tag)&lt;br&gt;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag = Tag.find_by_sync_id(tag_current.id) &#124;&#124; Tag.new&lt;br&gt;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.name = tag_current.name&lt;br&gt;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.sync_id = tag_current.id&lt;br&gt;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.save&lt;br&gt;&#38;nbsp;&#38;nbsp;end&lt;br&gt;end&lt;/code&gt;&lt;br&gt;&lt;br&gt;Thanks Farrel.</description>
		<content:encoded><![CDATA[<p>How fantastic. I took the above code and cut it down to just this:<br /><code>if soapResponse.getNewTagsSinceResult.respond_to? "tag"<br />&#38;nbsp;&#38;nbsp;for tag_current in Array(soapResponse.getNewTagsSinceResult.tag)<br />&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag = Tag.find_by_sync_id(tag_current.id) || Tag.new<br />&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.name = tag_current.name<br />&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.sync_id = tag_current.id<br />&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.save<br />&#38;nbsp;&#38;nbsp;end<br />end</code></p>
<p>Thanks Farrel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farrel Lifson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-15234</link>
		<dc:creator>Farrel Lifson</dc:creator>
		<pubDate>Thu, 11 May 2006 12:41:51 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-15234</guid>
		<description>I did some further experimenting and it seems it&#39;s recommended to use Array(object) instead of object.to_a.</description>
		<content:encoded><![CDATA[<p>I did some further experimenting and it seems it&#39;s recommended to use Array(object) instead of object.to_a.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Watson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-15233</link>
		<dc:creator>Paul Watson</dc:creator>
		<pubDate>Thu, 11 May 2006 12:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-15233</guid>
		<description>Thank you for those two comments Farrel. The last one is especially interesting. I&#39;ll give the to_a trick a try.</description>
		<content:encoded><![CDATA[<p>Thank you for those two comments Farrel. The last one is especially interesting. I&#39;ll give the to_a trick a try.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Watson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-776</link>
		<dc:creator>Paul Watson</dc:creator>
		<pubDate>Thu, 11 May 2006 10:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-776</guid>
		<description>How fantastic. I took the above code and cut it down to just this:
&lt;code&gt;if soapResponse.getNewTagsSinceResult.respond_to? "tag"
&#38;nbsp;&#38;nbsp;for tag_current in Array(soapResponse.getNewTagsSinceResult.tag)
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag = Tag.find_by_sync_id(tag_current.id) &#124;&#124; Tag.new
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.name = tag_current.name
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.sync_id = tag_current.id
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.save
&#38;nbsp;&#38;nbsp;end
end&lt;/code&gt;

Thanks Farrel.</description>
		<content:encoded><![CDATA[<p>How fantastic. I took the above code and cut it down to just this:<br />
<code>if soapResponse.getNewTagsSinceResult.respond_to? "tag"<br />
&#38;nbsp;&#38;nbsp;for tag_current in Array(soapResponse.getNewTagsSinceResult.tag)<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag = Tag.find_by_sync_id(tag_current.id) || Tag.new<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.name = tag_current.name<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.sync_id = tag_current.id<br />
&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;tag.save<br />
&#38;nbsp;&#38;nbsp;end<br />
end</code></p>
<p>Thanks Farrel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farrel Lifson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-775</link>
		<dc:creator>Farrel Lifson</dc:creator>
		<pubDate>Thu, 11 May 2006 07:41:51 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-775</guid>
		<description>I did some further experimenting and it seems it's recommended to use Array(object) instead of object.to_a.</description>
		<content:encoded><![CDATA[<p>I did some further experimenting and it seems it&#8217;s recommended to use Array(object) instead of object.to_a.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Watson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-774</link>
		<dc:creator>Paul Watson</dc:creator>
		<pubDate>Thu, 11 May 2006 07:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-774</guid>
		<description>Thank you for those two comments Farrel. The last one is especially interesting. I'll give the to_a trick a try.</description>
		<content:encoded><![CDATA[<p>Thank you for those two comments Farrel. The last one is especially interesting. I&#8217;ll give the to_a trick a try.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farrel Lifson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-15232</link>
		<dc:creator>Farrel Lifson</dc:creator>
		<pubDate>Thu, 11 May 2006 01:07:49 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-15232</guid>
		<description>Also if you really want to squeeze things down you can do this:&lt;br&gt;&lt;br&gt;@tag = Tag.find_by_syn_id(tag.id) &#124;&#124; Tag.new&lt;br&gt;@tag.name = tag.name&lt;br&gt;@tag.sync_id &#124;&#124;= tag.id&lt;br&gt;@tag.save</description>
		<content:encoded><![CDATA[<p>Also if you really want to squeeze things down you can do this:</p>
<p>@tag = Tag.find_by_syn_id(tag.id) || Tag.new<br />@tag.name = tag.name<br />@tag.sync_id ||= tag.id<br />@tag.save</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farrel Lifson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-15231</link>
		<dc:creator>Farrel Lifson</dc:creator>
		<pubDate>Thu, 11 May 2006 00:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-15231</guid>
		<description>I haven&#39;t used WSDLDriver but doe the tag object respond to to_a? If so you can do the following:&lt;br&gt;&lt;br&gt;if soapResponse.getNewTagsSinceResult.respond_to? "tag"&lt;br&gt;  for tag in soapResponse.getNewTagsSinceResult.tag.to_a&lt;br&gt;   @tag = Tag.find_by_sync_id(tag.id)&lt;br&gt;   if (@tag)&lt;br&gt;    @tag.name = tag.name&lt;br&gt;    @tag.save&lt;br&gt;   else&lt;br&gt;    @tag = Tag.new&lt;br&gt;    @tag.name = tag.name&lt;br&gt;    @tag.sync_id = tag.id&lt;br&gt;    @tag.save&lt;br&gt;   end&lt;br&gt;  end&lt;br&gt;end&lt;br&gt;&lt;br&gt;Just a quick warning that currently all objects respond to to_a but this will soon be deprecated so for future versions it&#39;s better to check that the tag object class explicity implements to_a.</description>
		<content:encoded><![CDATA[<p>I haven&#39;t used WSDLDriver but doe the tag object respond to to_a? If so you can do the following:</p>
<p>if soapResponse.getNewTagsSinceResult.respond_to? &#8220;tag&#8221;<br />  for tag in soapResponse.getNewTagsSinceResult.tag.to_a<br />   @tag = Tag.find_by_sync_id(tag.id)<br />   if (@tag)<br />    @tag.name = tag.name<br />    @tag.save<br />   else<br />    @tag = Tag.new<br />    @tag.name = tag.name<br />    @tag.sync_id = tag.id<br />    @tag.save<br />   end<br />  end<br />end</p>
<p>Just a quick warning that currently all objects respond to to_a but this will soon be deprecated so for future versions it&#39;s better to check that the tag object class explicity implements to_a.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farrel Lifson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-773</link>
		<dc:creator>Farrel Lifson</dc:creator>
		<pubDate>Wed, 10 May 2006 20:07:49 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-773</guid>
		<description>Also if you really want to squeeze things down you can do this:

@tag = Tag.find_by_syn_id(tag.id) &#124;&#124; Tag.new
@tag.name = tag.name
@tag.sync_id &#124;&#124;= tag.id
@tag.save</description>
		<content:encoded><![CDATA[<p>Also if you really want to squeeze things down you can do this:</p>
<p>@tag = Tag.find_by_syn_id(tag.id) || Tag.new<br />
@tag.name = tag.name<br />
@tag.sync_id ||= tag.id<br />
@tag.save</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farrel Lifson</title>
		<link>http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/comment-page-1/#comment-772</link>
		<dc:creator>Farrel Lifson</dc:creator>
		<pubDate>Wed, 10 May 2006 19:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://paulmwatson.com/journal/2006/05/10/a-dirty-ruby/#comment-772</guid>
		<description>I haven't used WSDLDriver but doe the tag object respond to to_a? If so you can do the following:

if soapResponse.getNewTagsSinceResult.respond_to? "tag"
  for tag in soapResponse.getNewTagsSinceResult.tag.to_a
   @tag = Tag.find_by_sync_id(tag.id)
   if (@tag)
    @tag.name = tag.name
    @tag.save
   else
    @tag = Tag.new
    @tag.name = tag.name
    @tag.sync_id = tag.id
    @tag.save
   end
  end
end

Just a quick warning that currently all objects respond to to_a but this will soon be deprecated so for future versions it's better to check that the tag object class explicity implements to_a.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t used WSDLDriver but doe the tag object respond to to_a? If so you can do the following:</p>
<p>if soapResponse.getNewTagsSinceResult.respond_to? &#8220;tag&#8221;<br />
  for tag in soapResponse.getNewTagsSinceResult.tag.to_a<br />
   @tag = Tag.find_by_sync_id(tag.id)<br />
   if (@tag)<br />
    @tag.name = tag.name<br />
    @tag.save<br />
   else<br />
    @tag = Tag.new<br />
    @tag.name = tag.name<br />
    @tag.sync_id = tag.id<br />
    @tag.save<br />
   end<br />
  end<br />
end</p>
<p>Just a quick warning that currently all objects respond to to_a but this will soon be deprecated so for future versions it&#8217;s better to check that the tag object class explicity implements to_a.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
