Class: Moneymarket::Market
- Inherits:
-
Object
- Object
- Moneymarket::Market
- Defined in:
- lib/moneymarket/core/market.rb
Instance Attribute Summary collapse
-
#account_provider ⇒ Object
readonly
Returns the value of attribute account_provider.
Instance Method Summary collapse
- #base_account_for(_order) ⇒ Object
- #destination_account_for(_order) ⇒ Object
- #exchange_base_account ⇒ Object
- #exchange_quote_account ⇒ Object
-
#initialize(_base_currency, _quote_currency, account_provider = nil) ⇒ Market
constructor
A new instance of Market.
- #preload_user_balances(_users) ⇒ Object
- #quote_account_for(_order) ⇒ Object
- #source_account_for(_order) ⇒ Object
Constructor Details
#initialize(_base_currency, _quote_currency, account_provider = nil) ⇒ Market
Returns a new instance of Market.
5 6 7 8 9 |
# File 'lib/moneymarket/core/market.rb', line 5 def initialize(_base_currency, _quote_currency, account_provider = nil) @base_currency = _base_currency @quote_currency = _quote_currency @account_provider = account_provider end |
Instance Attribute Details
#account_provider ⇒ Object (readonly)
Returns the value of attribute account_provider.
3 4 5 |
# File 'lib/moneymarket/core/market.rb', line 3 def account_provider @account_provider end |
Instance Method Details
#base_account_for(_order) ⇒ Object
23 24 25 |
# File 'lib/moneymarket/core/market.rb', line 23 def base_account_for(_order) account_provider.account_for(_order.user_id, base_currency) end |
#destination_account_for(_order) ⇒ Object
35 36 37 |
# File 'lib/moneymarket/core/market.rb', line 35 def destination_account_for(_order) public_send(_order.destination_account, _order) end |
#exchange_base_account ⇒ Object
15 16 17 |
# File 'lib/moneymarket/core/market.rb', line 15 def exchange_base_account account_provider.exchange_account_for base_currency end |
#exchange_quote_account ⇒ Object
19 20 21 |
# File 'lib/moneymarket/core/market.rb', line 19 def exchange_quote_account account_provider.exchange_account_for quote_currency end |
#preload_user_balances(_users) ⇒ Object
11 12 13 |
# File 'lib/moneymarket/core/market.rb', line 11 def preload_user_balances(_users) account_provider.preload_balances(_users, [_base_currency, _quote_currency]) end |
#quote_account_for(_order) ⇒ Object
27 28 29 |
# File 'lib/moneymarket/core/market.rb', line 27 def quote_account_for(_order) account_provider.account_for(_order.user_id, quote_currency) end |
#source_account_for(_order) ⇒ Object
31 32 33 |
# File 'lib/moneymarket/core/market.rb', line 31 def source_account_for(_order) public_send(_order.source_account, _order) end |