Commit b6d5c2a

mo khan <mo@mokhan.ca>
2014-03-18 03:38:55
connect stock service to fetch stock price for hard coded stock.
1 parent c77f6db
Changed files (3)
lib/boot/container_configuration.rb
@@ -6,6 +6,7 @@ class ContainerConfiguration
     container.register(:shell) { |x| x.build(ApplicationShell) }.as_singleton
     container.register(:shell_presenter) { |x| x.build(ApplicationShellPresenter) }.as_singleton
     container.register(:application_controller) { |x| x.build(ApplicationController) }.as_singleton
+    container.register(:stock_service) { |x| StockService.new }.as_singleton
     Spank::IOC.bind_to(container)
   end
 end
lib/domain/stock.rb
@@ -4,4 +4,8 @@ class Stock
   def initialize(name, symbol, price)
     @name, @symbol, @price = name, symbol, price
   end
+
+  def to_s
+    "#{symbol}: #{name} - #{price}"
+  end
 end
lib/presentation/presenters/application_shell_presenter.rb
@@ -1,9 +1,10 @@
 class ApplicationShellPresenter
   attr_reader :view
 
-  def initialize(shell, event_aggregator)
+  def initialize(shell, event_aggregator, stock_service)
     @view = shell
     @event_aggregator = event_aggregator
+    @stock_service = stock_service
   end
 
   def present
@@ -17,7 +18,9 @@ class ApplicationShellPresenter
   def changed(text)
     return if @updating
     update do
-      @view.display(text.reverse.upcase)
+      @view.display("...")
+      stock = @stock_service.fetch("ARX.TO")
+      @view.display(stock.to_s)
     end
   end