Class: DropletKit::Client
- Inherits:
-
Object
- Object
- DropletKit::Client
- Defined in:
- lib/droplet_kit/client.rb
Constant Summary collapse
- DIGITALOCEAN_API =
'https://api.digitalocean.com'
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #method_missing(name, *args, &block) ⇒ Object
- #resources ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/droplet_kit/client.rb', line 9 def initialize( = {}) @access_token = [:access_token] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/droplet_kit/client.rb', line 35 def method_missing(name, *args, &block) if self.class.resources.keys.include?(name) resources[name] ||= self.class.resources[name].new(connection: connection) resources[name] else super end end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
7 8 9 |
# File 'lib/droplet_kit/client.rb', line 7 def access_token @access_token end |
Class Method Details
.resources ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/droplet_kit/client.rb', line 19 def self.resources { actions: ActionResource, droplets: DropletResource, domains: DomainResource, domain_records: DomainRecordResource, droplet_actions: DropletActionResource, images: ImageResource, image_actions: ImageActionResource, regions: RegionResource, sizes: SizeResource, ssh_keys: SSHKeyResource, account: AccountResource, } end |
Instance Method Details
#connection ⇒ Object
13 14 15 16 17 |
# File 'lib/droplet_kit/client.rb', line 13 def connection Faraday.new() do |req| req.adapter :net_http end end |
#resources ⇒ Object
44 45 46 |
# File 'lib/droplet_kit/client.rb', line 44 def resources @resources ||= {} end |