Skip to content

Instantly share code, notes, and snippets.

@lucashungaro
Created May 14, 2012 00:51
Show Gist options
  • Save lucashungaro/2690990 to your computer and use it in GitHub Desktop.
Save lucashungaro/2690990 to your computer and use it in GitHub Desktop.
SRP snippet 3
class Game < ActiveRecord::Base
belongs_to :category
validates_presence_of :title, :category_id, :description,
:price, :platform, :year
def price
price = read_attribute(:price)
unless price.present?
update_attribute(:price, GamePriceService.new(self).get_price)
read_attribute(:price)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment