Don't really know how to call such busness-logic, so i called it message-update system. Pls, correct me)
I have such entitys:
- TradeMessage
- Trade
- Lot
- Bet
Trade has_many Lots. Lot has_many Bets.
Actually it has more associations. But "root" object is Trade.
Every update in Trade and it's associations must be initiated when new TradeMessage is created.
Specific TradeMessage can be annuled and Trade with it's associations should be recalculated.
For example:
- TradeMessage(id: 1, payload: {trade:{name: "New Trade"}}) --> New Trade was created
- TradeMessage(id: 2, payload: {trade:{lots: {number: 1}}}, trade_id: 1) --> New lot for our first trade was created
- TradeMessage(id: 3, payload: {trade:{lots: {number: 2}}}, trade_id: 1) --> New lot for our first trade was created
- TradeMessage.find(3).annul --> Trade and Lots returned to 2nd step
So what design pattern is it? And how to implenet this in Ruby on Rails?
Don't event to know how to google it correctly)
Aucun commentaire:
Enregistrer un commentaire