90d9c7e6893374ca03084010e57d4e21

Crazy Wedding Controller! Can you guys help me refactor it with more fun!

require 'family'
require 'friends'

class WeddingController < LifeController

  def we_are_getting_married
    @wedding.groom = 'ME'
    @wedding.bride = 'HER'
  end
  
  def wedding_location
    redirect_to :some_city => :some_country
  end
  
  def wedding_date
    @wedding.date = "2008.01.01"
  end
  
end

Refactorings

No refactoring yet !

5b279d677924919326946ef11330d3e4

lagsalot.myopenid.com

December 28, 2007, December 28, 2007 17:17, permalink

3 ratings. Login to rate!
require 'family'
require 'friends'

class WeddingController < LifeController

  def initialize
    puts "Congratulations"
    honeymoon_over if wedding.date < Time.now
  end

  def we_are_getting_married
    @wedding.groom = 'ME'
    @wedding.bride = 'HER'
  end
  
  def wedding_location
    redirect_to :some_city => :some_country
  end
  
  def wedding_date
    @wedding.date = "2008.01.01"
  end

  def honeymoon_over
    @wedding = nil && drain_bank
  end

  def drain_bank
    @wife = Wife.new
    while account_balance > 0.00
      account_balance = account_balance - @wife.shoes.price
      account_balance = account_balance - @wife.cloths.price
      account_balance = account_balance - @wife.car.price
      account_balance = account_balance - @wife.furnishings.price
      account_balance = oh_damn if @wife.spawned_offspring?
    end
  end

  def oh_damn
    - 200000.00 * @wife.spawn.count
  end
 
end

Your refactoring





Format Copy from initial code

or Cancel