Class: Round::AccountCollection
- Inherits:
-
Collection
- Object
- Base
- Collection
- Round::AccountCollection
- Defined in:
- lib/round/account.rb
Instance Attribute Summary
Attributes inherited from Collection
Attributes inherited from Base
Instance Method Summary collapse
- #content_type ⇒ Object
- #create(name:, network:) ⇒ Object
-
#initialize(options = {}) ⇒ AccountCollection
constructor
A new instance of AccountCollection.
- #refresh ⇒ Object
Methods inherited from Collection
#[], #add, #method_missing, #populate_data
Methods inherited from Base
association, #hash_identifier, hash_identifier, #method_missing
Constructor Details
#initialize(options = {}) ⇒ AccountCollection
Returns a new instance of AccountCollection.
45 46 47 48 49 |
# File 'lib/round/account.rb', line 45 def initialize( = {}) raise ArgumentError, 'AccountCollection must be associated with a wallet' unless [:wallet] @wallet = [:wallet] super() { |account| account.wallet = @wallet } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Round::Collection
Instance Method Details
#content_type ⇒ Object
51 52 53 |
# File 'lib/round/account.rb', line 51 def content_type Round::Account end |
#create(name:, network:) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/round/account.rb', line 55 def create(name:, network:) unless [:bitcoin_testnet, :bitcoin, :litecoin, :dogecoin].include?(network) raise ArgumentError, 'Network must be :bitcoin_testnet, :dogecoin, :litecoin, :bitcoin.' end resource = @resource.create(name: name, network: network) account = Round::Account.new(resource: resource, wallet: @wallet, client: @client) add(account) account end |
#refresh ⇒ Object
65 66 67 |
# File 'lib/round/account.rb', line 65 def refresh super(wallet: @wallet) end |