Created
March 24, 2015 21:43
-
-
Save kchens/a6c0baee2fd69f9b43b7 to your computer and use it in GitHub Desktop.
"Skinny" StockController - ServiceObject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ###################### | |
# Refactored | |
# ###################### | |
# app/services/stock_service.rb | |
class StockService | |
def initialize(user) | |
@user = user | |
@stocks = [] | |
@stock_symbols = [] | |
end | |
def get_user_stock_symbols | |
@user.stocks.each do |stock| | |
@stock_symbols << stock.symbol | |
end | |
end | |
def update_stocks | |
@stock_symbols.each do |symbol| | |
@stocks << StockQuote::Stock.quote(symbol, nil, nil, | |
[ "Symbol", | |
"Name", | |
"LastTradePriceOnly" | |
] ) | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment