Class: BlockchainNode::Client
- Inherits:
-
Object
- Object
- BlockchainNode::Client
- Defined in:
- lib/blockchain-node/client.rb
Defined Under Namespace
Classes: AuthToken
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#node_id ⇒ Object
readonly
Returns the value of attribute node_id.
Instance Method Summary collapse
- #auth_token ⇒ Object
-
#initialize(node_id) ⇒ Client
constructor
A new instance of Client.
-
#nodes ⇒ Object
convenience method to get nodes index.
Constructor Details
#initialize(node_id) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/blockchain-node/client.rb', line 10 def initialize(node_id) @node_id = node_id # allow a different configuration per client instance @configuration = BlockchainNode::Configuration.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
catch all other method calls and assume its the RPC method call
30 31 32 33 |
# File 'lib/blockchain-node/client.rb', line 30 def method_missing(method, *args, &block) data = { method: method, parameters: args } request.post(path: nodes_path, data: data, auth_token: auth_token) end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/blockchain-node/client.rb', line 8 def configuration @configuration end |
#node_id ⇒ Object (readonly)
Returns the value of attribute node_id.
7 8 9 |
# File 'lib/blockchain-node/client.rb', line 7 def node_id @node_id end |
Instance Method Details
#auth_token ⇒ Object
21 22 23 24 25 |
# File 'lib/blockchain-node/client.rb', line 21 def auth_token @@_auth_token ||= get_new_auth_token @@_auth_token = get_new_auth_token if auth_token_expired? @@_auth_token.token end |
#nodes ⇒ Object
convenience method to get nodes index
17 18 19 |
# File 'lib/blockchain-node/client.rb', line 17 def nodes request.get(path: node_index_path, auth_token: auth_token) end |