Class: OmiseGO::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/omisego/base.rb
Direct Known Subclasses
Account, AuthenticationToken, Balance, Error, Exchange, List, Pagination, Setting, Token, Transaction, TransactionSource, User, Wallet
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes, client: nil) ⇒ Base
Returns a new instance of Base.
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/omisego/base.rb', line 22
def initialize(attributes, client: nil)
self.class.attributes_list ||= []
self.class.attributes_list.each do |name|
instance_variable_set("@#{name}", attributes[name.to_sym] ||
attributes[name.to_s])
end
self.original_payload = attributes
@client = client || self.class.global_client
end
|
Class Attribute Details
.attributes_list ⇒ Object
Returns the value of attribute attributes_list.
4
5
6
|
# File 'lib/omisego/base.rb', line 4
def attributes_list
@attributes_list
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
20
21
22
|
# File 'lib/omisego/base.rb', line 20
def client
@client
end
|
#original_payload ⇒ Object
Returns the value of attribute original_payload.
20
21
22
|
# File 'lib/omisego/base.rb', line 20
def original_payload
@original_payload
end
|
Class Method Details
.attributes(*attrs) ⇒ Object
6
7
8
9
|
# File 'lib/omisego/base.rb', line 6
def attributes(*attrs)
attr_accessor(*attrs)
@attributes_list = attrs.map(&:to_sym)
end
|
.global_client ⇒ Object
11
12
13
|
# File 'lib/omisego/base.rb', line 11
def global_client
Client.new
end
|
.request(client) ⇒ Object
15
16
17
|
# File 'lib/omisego/base.rb', line 15
def request(client)
(client || global_client).request
end
|
Instance Method Details
#error? ⇒ Boolean
46
47
48
|
# File 'lib/omisego/base.rb', line 46
def error?
false
end
|
#inspect ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/omisego/base.rb', line 34
def inspect
string = "#<#{self.class.name}:#{object_id} "
fields = self.class.attributes_list.map do |field|
"#{field}: #{send(field)}"
end
string << fields.join(', ') << '>'
end
|
#success? ⇒ Boolean
42
43
44
|
# File 'lib/omisego/base.rb', line 42
def success?
true
end
|