Class: Bitsor::Normalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/bitsor/normalizer.rb

Constant Summary collapse

SCHEMAS =
{
  account_balances: 'normalize_account_balances',
  account_fees: 'normalize_account_fees',
  account_status: 'normalize_account',
  book: 'normalize_book',
  funding: 'normalize_funding',
  ledger: 'normalize_ledger',
  order: 'normalize_order',
  ticker: 'normalize_ticker',
  trade: 'normalize_trade',
  user_trade: 'normalize_user_trade',
}.freeze

Instance Method Summary collapse

Instance Method Details

#with(type) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bitsor/normalizer.rb', line 20

def with(type)
  method = SCHEMAS[type.to_sym] || :null_normalizer

  response = yield

  if response.class == Array
    return response.map do |response_element|
      send method, response_element
    end
  end

  send method, response
end