Skip to content

Instantly share code, notes, and snippets.

@adgilfillan
Created May 9, 2013 20:50
Show Gist options
  • Save adgilfillan/5550525 to your computer and use it in GitHub Desktop.
Save adgilfillan/5550525 to your computer and use it in GitHub Desktop.
class Pitcher < ActiveRecord::Base
attr_accessible :age, :name, :whip
alias :whip_1 :whip
(2..7).each do |num|
define_method("whip_#{num}") do
if self.age < 28
eval("self.whip_#{num-1}") * 0.95
else
eval("self.whip_#{num-1}") * 1.05
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment