Class: Ask::TokenUsage::LedgerEntry
- Inherits:
-
Data
- Object
- Data
- Ask::TokenUsage::LedgerEntry
- Defined in:
- lib/ask/token_usage/ledger_entry.rb
Overview
An immutable entry in a wallet's ledger.
kind is one of:
:grant — tokens added (carries +expires_at+ when expiring)
:debit — tokens spent (negative +amount+)
:adjustment — manual correction
:expiry — tokens removed because their grant expired
amount is signed: positive for grants/adjustments, negative for
debits and expiries. balance is the wallet's running balance after
the entry.
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
- #adjustment? ⇒ Boolean
- #credit? ⇒ Boolean
- #debit? ⇒ Boolean
- #debit_amount ⇒ Object
- #expiry? ⇒ Boolean
- #grant? ⇒ Boolean
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def amount @amount end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def balance @balance end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def created_at @created_at end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def expires_at @expires_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def kind @kind end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def @metadata end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
17 18 19 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 17 def reason @reason end |
Instance Method Details
#adjustment? ⇒ Boolean
26 27 28 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 26 def adjustment? kind == :adjustment end |
#credit? ⇒ Boolean
34 35 36 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 34 def credit? amount.positive? end |
#debit? ⇒ Boolean
22 23 24 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 22 def debit? kind == :debit end |
#debit_amount ⇒ Object
38 39 40 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 38 def debit_amount amount.negative? ? amount.abs : 0 end |
#expiry? ⇒ Boolean
30 31 32 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 30 def expiry? kind == :expiry end |
#grant? ⇒ Boolean
18 19 20 |
# File 'lib/ask/token_usage/ledger_entry.rb', line 18 def grant? kind == :grant end |