Class: StellarBase::FeeRequests::CallWithdrawFeeFixedQuoteFrom

Inherits:
Object
  • Object
show all
Defined in:
app/services/stellar_base/fee_requests/call_withdraw_fee_fixed_quote_from.rb

Constant Summary collapse

FEE_FIXED_QUOTE_FROM_ERROR =
"`fee_fixed_quote_from` must be a string of an object " \
"that responds to `.call` or the object itself".freeze

Class Method Summary collapse

Class Method Details

.call(fee_request:, fee_fixed_quote_from:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/services/stellar_base/fee_requests/call_withdraw_fee_fixed_quote_from.rb', line 8

def self.call(fee_request:, fee_fixed_quote_from:)
  asset_details = asset_details_from(fee_request)

  if fee = asset_details[:fee_fixed]
    return fee
  end

  return 0.0 if fee_fixed_quote_from.nil?

  callback = callback_from(fee_fixed_quote_from)
  callback.(fee_request)
end

.callback_from(fee_fixed_quote_from) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'app/services/stellar_base/fee_requests/call_withdraw_fee_fixed_quote_from.rb', line 21

def self.callback_from(fee_fixed_quote_from)
  fee_fixed_quote_from = GetCallbackFrom.(fee_fixed_quote_from)

  if !fee_fixed_quote_from.respond_to?(:call)
    fail ArgumentError, FEE_FIXED_QUOTE_FROM_ERROR
  end

  fee_fixed_quote_from
end