<?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:users1548</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/1548" rel="self"/>
  <title>webandy.myopenid.com</title>
  <updated>Wed Jun 24 00:02:16 -0700 2009</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor168529</id>
    <published>2009-06-24T00:02:16-07:00</published>
    <title>[Ruby] On Extract method</title>
    <content type="html">&lt;p&gt;Awesome, I made a module following your approach, thanks for your time.&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>webandy.myopenid.com</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/915-extract-method/refactors/168529" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code915</id>
    <published>2009-06-12T15:28:06-07:00</published>
    <updated>2009-06-24T00:02:17-07:00</updated>
    <title>[Ruby] Extract method</title>
    <content type="html">&lt;p&gt;Hello. This is from my blogging app. I'd like to extract a private method that would call group_by for an array of items passed to it, and take a method argument for what to group the records by. At least the first two code lines are exactly the same. I tried using eval() but was unsuccessful at passing a method argument in to be used within the group_by block. any help?&lt;/p&gt;

&lt;pre&gt;# stats is an array

@popular_urls = stats.group_by{|s| s.request_uri}.sort_by {|s| s.second.size}.reverse
@referrers = stats.group_by{|s| s.referrer}.sort_by {|s| s.second.size}.reverse
@ip_addresses = stats.reject{|s| s.remote_ip.blank?}.group_by{|s| s.remote_ip}.sort_by {|s| s.second.size}.reverse
@searches = Search.all.group_by{|s| s.query}.sort_by {|s| s.second.size}.reverse # FIXME go through site.searches association
&lt;/pre&gt;</content>
    <author>
      <name>webandy.myopenid.com</name>
      <email>no-email@refactormycode.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/915-extract-method" rel="alternate"/>
  </entry>
</feed>

