How to rewrite rails group_by class method as scope
<p>I would like to rewrite my class method as a scope.</p>

<pre><code>class Team

 def self.grouped
   self.all.group_by { |e| e.type }.map { |k, v| { k =&gt; v.group_by { |e| e.sub_type } } }
 end

end
</code></pre>

<p>How would I write as a scope?</p>

<pre><code>class Team

 #  scope :grouped ??

end
</code></pre>