Class: Coinbase::Validator
- Inherits:
-
Object
- Object
- Coinbase::Validator
- Defined in:
- lib/coinbase/validator.rb
Overview
A representation of a staking validator.
Class Method Summary collapse
-
.fetch(network_id, asset_id, validator_id) ⇒ Coinbase::Validator
Returns a Validator for the provided network, asset, and validator.
-
.list(network_id, asset_id, status: nil) ⇒ Enumerable<Coinbase::Validator>
Returns a list of Validators for the provided network and asset.
- .list_page(network_id, asset_id, status, page) ⇒ Object
- .validators_api ⇒ Object
Instance Method Summary collapse
-
#initialize(model) ⇒ Validator
constructor
Returns a new Validator object.
-
#inspect ⇒ String
Same as to_s.
-
#status ⇒ Symbol
Returns the status of the Validator.
-
#to_s ⇒ String
Returns a string representation of the Validator.
-
#validator_id ⇒ String
Returns the public identifiable id of the Validator.
Constructor Details
#initialize(model) ⇒ Validator
Returns a new Validator object.
8 9 10 |
# File 'lib/coinbase/validator.rb', line 8 def initialize(model) @model = model end |
Class Method Details
.fetch(network_id, asset_id, validator_id) ⇒ Coinbase::Validator
Returns a Validator for the provided network, asset, and validator.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/coinbase/validator.rb', line 30 def self.fetch(network_id, asset_id, validator_id) validator = Coinbase.call_api do validators_api.get_validator( network_id, asset_id, validator_id ) end new(validator) end |
.list(network_id, asset_id, status: nil) ⇒ Enumerable<Coinbase::Validator>
Returns a list of Validators for the provided network and asset.
17 18 19 20 21 22 23 |
# File 'lib/coinbase/validator.rb', line 17 def self.list(network_id, asset_id, status: nil) Coinbase::Pagination.enumerate( ->(page) { list_page(network_id, asset_id, status, page) } ) do |validator| new(validator) end end |
.list_page(network_id, asset_id, status, page) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/coinbase/validator.rb', line 65 def self.list_page(network_id, asset_id, status, page) Coinbase.call_api do validators_api.list_validators( network_id, asset_id, { status: status, page: page } ) end end |
.validators_api ⇒ Object
78 79 80 |
# File 'lib/coinbase/validator.rb', line 78 def self.validators_api Coinbase::Client::ValidatorsApi.new(Coinbase.configuration.api_client) end |
Instance Method Details
#inspect ⇒ String
Same as to_s.
61 62 63 |
# File 'lib/coinbase/validator.rb', line 61 def inspect to_s end |
#status ⇒ Symbol
Returns the status of the Validator.
49 50 51 |
# File 'lib/coinbase/validator.rb', line 49 def status @model.status end |
#to_s ⇒ String
Returns a string representation of the Validator.
55 56 57 |
# File 'lib/coinbase/validator.rb', line 55 def to_s "Coinbase::Validator{id: '#{validator_id}' status: '#{status}'}" end |
#validator_id ⇒ String
Returns the public identifiable id of the Validator.
43 44 45 |
# File 'lib/coinbase/validator.rb', line 43 def validator_id @model.validator_id end |