Class: Round::AccountCollection

Inherits:
Collection show all
Defined in:
lib/round/account.rb

Instance Attribute Summary

Attributes inherited from Collection

#collection

Attributes inherited from Base

#resource

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


45
46
47
48
49
# File 'lib/round/account.rb', line 45

def initialize(options = {})
  raise ArgumentError, 'AccountCollection must be associated with a wallet' unless options[:wallet]
  @wallet = options[:wallet]
  super(options) { || .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_typeObject



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)
   = Round::Account.new(resource: resource, wallet: @wallet, client: @client)
  add()
  
end

#refreshObject



65
66
67
# File 'lib/round/account.rb', line 65

def refresh
  super(wallet: @wallet)
end