<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users935</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/935" rel="self"/>
  <title>bakkdoor</title>
  <updated>Tue Aug 19 15:44:04 -0700 2008</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor15307</id>
    <published>2008-08-19T15:44:04-07:00</published>
    <title>[Ruby] On link_to for tags</title>
    <content type="html">&lt;p&gt;something like this?&lt;/p&gt;

&lt;pre&gt;def link_to_tags(tags)
  tags.collect { |tag| link_to tag, tags_path_for(tag) }.join(&amp;quot;,&amp;quot;)
end&lt;/pre&gt;</content>
    <author>
      <name>bakkdoor</name>
      <email>bakkdoor@flasht.de</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/448-link_to-for-tags/refactors/15307" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor14930</id>
    <published>2008-08-13T02:20:38-07:00</published>
    <title>[Ruby] On Similar Methods Refactoring</title>
    <content type="html">&lt;p&gt;make that a class method, the way it is written right now..
&lt;br /&gt;like so:&lt;/p&gt;

&lt;pre&gt;# creates those methods for you

def self.should_be_upgraded_to(title, id)
  define_method &amp;quot;should_be_upgraded_to_#{title}?&amp;quot; do
    rank = Rank.find_by_id(id)
    if self.cbc &amp;gt;= rank.cbc &amp;amp;&amp;amp; self.dbc &amp;gt;= rank.dbc &amp;amp;&amp;amp;
       self.cbp &amp;gt;= rank.cbp &amp;amp;&amp;amp; self.dbp &amp;gt;= rank.dbp &amp;amp;&amp;amp;
       self.cbs &amp;gt;= rank.cbs &amp;amp;&amp;amp; self.dbs &amp;gt;= rank.dbs &amp;amp;&amp;amp;
       self.cpd &amp;gt;= rank.cpd &amp;amp;&amp;amp; self.dpd &amp;gt;= rank.dpd &amp;amp;&amp;amp;
       self.cpe &amp;gt;= rank.cpe &amp;amp;&amp;amp; self.dpe &amp;gt;= rank.dpe &amp;amp;&amp;amp;       
       self.cpa &amp;gt;= rank.cpa &amp;amp;&amp;amp; self.dpa &amp;gt;= rank.dpa &amp;amp;&amp;amp;
       self.cnb &amp;gt;= rank.cnb &amp;amp;&amp;amp; self.dnb &amp;gt;= rank.dnb &amp;amp;&amp;amp;
       self.cad &amp;gt;= rank.cad &amp;amp;&amp;amp; self.dad &amp;gt;= rank.dad then true
    else
       false
    end
  end
end


# create them like this in your class:

should_be_upgraded_to :apprentice, 1
should_be_upgraded_to :practitioner, 2
should_be_upgraded_to :master, 3
should_be_upgraded_to :designer, 4
should_be_upgraded_to :engineer, 5
should_be_upgraded_to :architect, 6

# i hope it works, haven't actually tried it out...&lt;/pre&gt;</content>
    <author>
      <name>bakkdoor</name>
      <email>bakkdoor@flasht.de</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/432-similar-methods-refactoring/refactors/14930" rel="alternate"/>
  </entry>
</feed>

