<?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/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
	>
<channel>
	<title>Comments on: Skipping ActiveRecord Callback Methods</title>
	<atom:link href="http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/feed/" rel="self" type="application/rss+xml" />
	<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/</link>
	<description>Revolutionary Teams, Organizational Transformation</description>
	<lastBuildDate>Fri, 23 Mar 2012 18:05:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Georg Ledermann</title>
		<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/comment-page-1/#comment-2</link>
		<dc:creator>Georg Ledermann</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/#comment-2</guid>
		<description>&lt;p&gt;Thank you for this tip! But: Your skip_callback method does not handle the result of the yielded block. If have fixed it with this code:&lt;/p&gt;


&lt;pre&gt;
  def self.skip_callback(callback, &amp;block)
    method = instance_method(callback)
    remove_method(callback) if respond_to?(callback)
    define_method(callback){ true }
    result = yield
    remove_method(callback)
    define_method(callback, method)
    result
  end
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Thank you for this tip! But: Your skip_callback method does not handle the result of the yielded block. If have fixed it with this code:</p>
<pre>
  def self.skip_callback(callback, &#38;block)
    method = instance_method(callback)
    remove_method(callback) if respond_to?(callback)
    define_method(callback){ true }
    result = yield
    remove_method(callback)
    define_method(callback, method)
    result
  end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Forexman</title>
		<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/comment-page-1/#comment-3</link>
		<dc:creator>Forexman</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/#comment-3</guid>
		<description>&lt;p&gt;Hi. This is really interesting post. Thank You! I have just subscribed to Your rss!&lt;/p&gt;


	&lt;p&gt;Best regards&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hi. This is really interesting post. Thank You! I have just subscribed to Your rss!</p>
<p>Best regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart</title>
		<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/comment-page-1/#comment-4</link>
		<dc:creator>Bart</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/#comment-4</guid>
		<description>&lt;p&gt;Really usefull solution to me! I used this in a module and didn&#8217;t get it working on first until I read about the difference between including and extending a module. For all developers getting the same problem, I found a lot of usefull info on this url:&lt;/p&gt;


	&lt;p&gt;http://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Really usefull solution to me! I used this in a module and didn&#8217;t get it working on first until I read about the difference between including and extending a module. For all developers getting the same problem, I found a lot of usefull info on this url:</p>
<p><a href="http://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/" rel="nofollow">http://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Georg Ledermann</title>
		<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/comment-page-1/#comment-5</link>
		<dc:creator>Georg Ledermann</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/#comment-5</guid>
		<description>&lt;p&gt;One more addition: Bad things happen if an exception is raised in the yielded block &#8211; the former callback is not restored. To avoid this I have changed the method like this:&lt;/p&gt;


&lt;pre&gt;
  def self.skip_callback(callback, &amp;block)
    method = instance_method(callback)
    remove_method(callback) if respond_to?(callback)
    define_method(callback){ true }
    begin
      result = yield
    ensure
      # Always redefine the old callback, even if
      # there were exceptions raised in the yielded block
      remove_method(callback)
      define_method(callback, method)
    end
    result
  end
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>One more addition: Bad things happen if an exception is raised in the yielded block &#8211; the former callback is not restored. To avoid this I have changed the method like this:</p>
<pre>
  def self.skip_callback(callback, &#38;block)
    method = instance_method(callback)
    remove_method(callback) if respond_to?(callback)
    define_method(callback){ true }
    begin
      result = yield
    ensure
      # Always redefine the old callback, even if
      # there were exceptions raised in the yielded block
      remove_method(callback)
      define_method(callback, method)
    end
    result
  end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vojtech Salbaba</title>
		<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/comment-page-1/#comment-6</link>
		<dc:creator>Vojtech Salbaba</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/#comment-6</guid>
		<description>&lt;p&gt;What i find even more interesting is that it works even it the callback itself.&lt;/p&gt;


&lt;pre&gt;
class Person &lt; ActiveRecord::Base
 after_save :create_another

 def create_another
  Person.skip_callback(&quot;create_brother&quot;) do
   Person.create(:name =&gt; &quot;peter&quot;)
  end
 end
end

Person.create :name =&gt; &quot;ronald&quot;
This code will not explode, even though the method removes itself and then add itself back (gives me headache).</description>
		<content:encoded><![CDATA[<p>What i find even more interesting is that it works even it the callback itself.</p>
<pre>
class Person &lt; ActiveRecord::Base
 after_save :create_another

 def create_another
  Person.skip_callback("create_brother") do
   Person.create(:name =&gt; "peter")
  end
 end
end

Person.create :name =&gt; "ronald"
This code will not explode, even though the method removes itself and then add itself back (gives me headache).</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vojtech Salbaba</title>
		<link>http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/comment-page-1/#comment-7</link>
		<dc:creator>Vojtech Salbaba</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://integrumtech.com/2007/12/skipping-activerecord-callback-methods/#comment-7</guid>
		<description>&lt;p&gt;Hm. Please close the pre tag behind me, thank you :)&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Hm. Please close the pre tag behind me, thank you :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: integrumtech.com @ 2012-05-17 01:09:40 -->
