lib/orders/order_book.rb in orders-0.0.4 vs lib/orders/order_book.rb in orders-0.0.5

- old
+ new

@@ -1,11 +1,13 @@ module Orders # Represents DOM (OrderBook) for one security # индекс стакана по цене class OrderBook < IndexedList - attr_accessor :isin_id, :changed + attr_accessor :changed + attr_reader :isin_id + alias isin isin_id def initialize isin_id @isin_id = isin_id @changed = true super() @@ -13,23 +15,26 @@ def index item item.price end - def add item - if item.price > 0 + def check item + item.price > 0 + end + + def add? item + if super @changed = true # Marking DOM as changed item.order_book = self - super - else - self + item end end - # Does not call super! - def remove item - @changed = true if delete index item # Marking DOM as changed - item.order_book = nil - self + def remove? item + if super + @changed = true # Marking DOM as changed + item.order_book = nil + item + end end end end