title: Alternative to Ruby Case statement
body: <p>I am currently writing a program for a banking administration system using Ruby. One of the capabilities of this system is that it can create a new account, accounts can be one of six types.</p>
  
  <p><strong>I have the following method in my controller to cater for this function:</strong></p>
  
  <pre><code>def create_account(type, holder)
    case type
    when :current  then CurrentAccount.new(holder, @account_number)
    when :savings  then SavingsAccount.new(holder, @account_number)
    when :business then BusinessAccount.new(holder, @account_number)
    when :ir       then IRAccount.new(holder, @account_number)
    when :smb      then SMBAccount.new(holder, @account_number)
    when :student  then StudentAccount.new(holder, @account_number)
    end
  end
  </code></pre>
  
  <p>Each of these accounts inherits from a base account and will eventually contain individual attributes, e.g. Interest rate, overdraft, etc.</p>
  
  <p>Although this is functional and delivers the required results it feels a bit lengthy. However I can't think of any obvious ways to refactor.</p>
  
  <p>Any suggestions welcome...</p>