title: Converting inheritance to composition in rails
body: <p>I have a model in a legacy system that looks something like this:</p>
  
  <pre><code> class Prize &lt; ActiveRecord::Base
  
     def win
       # do a bunch of things
     end
   end
  </code></pre>
  
  <p>We started off with one prize, but like anything else the type of prizes we are dealing with is starting to expand.  So now def win is doing a whole bunch of case/switching to decide prize type.  </p>
  
  <p>For that reason I decided to do this:</p>
  
  <pre><code>class DailyPrize &lt; Prize
     def win
       #do only daily prize stuff, no type checking.
     end
  end
  </code></pre>
  
  <p>This code came under review before we sent it off to QA and now I am asked to do this using composition (mixin) and not subclassing.  I cannot think of a clean way to do this.</p>
  
  <p>The legacy code base is doing the following in a bunch of places and I did not want to go changing stuff all over the place:</p>
  
  <p>prize = Prize.new
  prize.win</p>
  
  <p>So, my question how to make this happen using composition? </p>