Class: Stonk::Service
- Inherits:
-
Object
- Object
- Stonk::Service
- Defined in:
- lib/stonk/service.rb
Instance Method Summary collapse
- #get_stock_price(stock_symbol) ⇒ Object
-
#initialize(lookup_adapters: [], cache_adapter: nil) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(lookup_adapters: [], cache_adapter: nil) ⇒ Service
Returns a new instance of Service.
5 6 7 8 |
# File 'lib/stonk/service.rb', line 5 def initialize(lookup_adapters: [], cache_adapter: nil) @lookup_adapters = lookup_adapters @cache_adapter = cache_adapter end |
Instance Method Details
#get_stock_price(stock_symbol) ⇒ Object
10 11 12 13 14 |
# File 'lib/stonk/service.rb', line 10 def get_stock_price(stock_symbol) get_stock_price_from_adapters(stock_symbol).tap do |price| @cache_adapter.set_stock_price(stock_symbol, price) if has_cache_adapter? end end |