Skip to content

Instantly share code, notes, and snippets.

@perezpaya
Created March 28, 2016 22:57
Show Gist options
  • Save perezpaya/66baed041d990edd7520 to your computer and use it in GitHub Desktop.
Save perezpaya/66baed041d990edd7520 to your computer and use it in GitHub Desktop.
class Company < Model
attribute :stock_symbol, type: String
attribute :name, type: String
attribute :stock_price, type: Float
attribute :stock_volume, type: Integer
attribute :number_of_shares, type: Integer
has_one :ceo, class_name: 'Person'
def volume_price
stock_price * stock_volume
end
def valuation
stock_price * number_of_shares
end
end
class Person < Model
attribute :name, type: String
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment