aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/wholesale_product.rb
blob: e1a1a4c8b13a79bf9a57d621c8cfc590a4f15b0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
class WholesaleProduct < ActiveRecord::Base

  after_initialize :set_prices

  def set_prices
    if msrp.nil? && !wholesale.nil?
      self.msrp = 2 * wholesale
    elsif !msrp.nil? && wholesale.nil?
      self.wholesale = msrp / 2
    end
  end

end