Module: NanoRpc::AccountsHelper
- Includes:
- ApplicationHelper
- Included in:
- Accounts
- Defined in:
- lib/nano_rpc/helpers/accounts_helper.rb
Instance Method Summary collapse
- #<<(val) ⇒ Object
-
#[](idx) ⇒ Object
Array-like access for NanoRpc::Account.
- #balances ⇒ Object
- #each(&_block) ⇒ Object
- #frontiers ⇒ Object
- #move(from:, to:) ⇒ Object
- #pending(count:, threshold: nil, source: nil, include_active: nil) ⇒ Object (also: #pending_blocks)
- #pending_balances ⇒ Object (also: #balances_pending)
- #to_a ⇒ Object
Instance Method Details
#<<(val) ⇒ Object
46 47 48 49 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 46 def <<(val) @to_a = nil @addresses << val end |
#[](idx) ⇒ Object
Array-like access for NanoRpc::Account
41 42 43 44 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 41 def [](idx) return unless addresses[idx] to_a[idx] end |
#balances ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 5 def balances accounts_balances .balances .each_with_object({}) do |(k, v), hash| hash[k] = v['balance'] end end |
#each(&_block) ⇒ Object
51 52 53 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 51 def each(&_block) to_a.each { |account| yield account } end |
#frontiers ⇒ Object
22 23 24 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 22 def frontiers accounts_frontiers.frontiers end |
#move(from:, to:) ⇒ Object
26 27 28 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 26 def move(from:, to:) account_move(source: from, wallet: to).moved == 1 end |
#pending(count:, threshold: nil, source: nil, include_active: nil) ⇒ Object Also known as: pending_blocks
30 31 32 33 34 35 36 37 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 30 def pending(count:, threshold: nil, source: nil, include_active: nil) accounts_pending( count: count, threshold: threshold, source: source, include_active: include_active ).blocks end |
#pending_balances ⇒ Object Also known as: balances_pending
13 14 15 16 17 18 19 |
# File 'lib/nano_rpc/helpers/accounts_helper.rb', line 13 def pending_balances accounts_balances .balances .each_with_object({}) do |(k, v), hash| hash[k] = v['pending'] end end |