Class: Bcoin::Client::Base
- Inherits:
-
Object
- Object
- Bcoin::Client::Base
show all
- Includes:
- HttpMethods
- Defined in:
- lib/bcoin/client/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#delete, #get, #post, #put
Constructor Details
#initialize(client, attr = {}) ⇒ Base
Returns a new instance of Base.
9
10
11
12
|
# File 'lib/bcoin/client/base.rb', line 9
def initialize client, attr = {}
@client = client
self.attributes = attr
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/bcoin/client/base.rb', line 67
def method_missing method, *args
if @attributes[method].nil?
raise NoMethodError
else
@attributes[method]
end
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
7
8
9
|
# File 'lib/bcoin/client/base.rb', line 7
def attributes
@attributes
end
|
#client ⇒ Object
Returns the value of attribute client.
7
8
9
|
# File 'lib/bcoin/client/base.rb', line 7
def client
@client
end
|
Instance Method Details
#base_path ⇒ Object
Override this in sub class
24
25
26
|
# File 'lib/bcoin/client/base.rb', line 24
def base_path
'/base'
end
|
#error ⇒ Object
45
46
47
|
# File 'lib/bcoin/client/base.rb', line 45
def error
@attributes[:error]
end
|
#error=(_error) ⇒ Object
49
50
51
|
# File 'lib/bcoin/client/base.rb', line 49
def error= _error
@attributes[:error] = _error
end
|
#id ⇒ Object
Override this in sub class
19
20
21
|
# File 'lib/bcoin/client/base.rb', line 19
def id
'base'
end
|
#inspect ⇒ Object
14
15
16
|
# File 'lib/bcoin/client/base.rb', line 14
def inspect
printf "#<%s @attributes=%p>", self.class.name, @attributes
end
|
#refresh! ⇒ Object
28
29
30
31
|
# File 'lib/bcoin/client/base.rb', line 28
def refresh!
self.attributes = get '/'
self
end
|
#respond_to?(method, include_all = false) ⇒ Boolean
53
54
55
|
# File 'lib/bcoin/client/base.rb', line 53
def respond_to? method, include_all = false
@attributes[method] ? true : super
end
|
#token=(_token) ⇒ Object
37
38
39
|
# File 'lib/bcoin/client/base.rb', line 37
def token= _token
@attributes[:token] = _token
end
|
#wallet_token ⇒ Object
33
34
35
|
# File 'lib/bcoin/client/base.rb', line 33
def wallet_token
@attributes[:token] if @attributes
end
|