Class: CloudRunner::DigitalOcean::Api
- Inherits:
-
Object
- Object
- CloudRunner::DigitalOcean::Api
- Defined in:
- lib/cloud_runner/digital_ocean/api.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client_id, api_key) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(client_id, api_key) ⇒ Api
Returns a new instance of Api.
6 7 8 9 |
# File 'lib/cloud_runner/digital_ocean/api.rb', line 6 def initialize(client_id, api_key) @client_id = client_id @api_key = api_key end |
Class Method Details
.delegate(method_name) ⇒ Object
28 29 30 |
# File 'lib/cloud_runner/digital_ocean/api.rb', line 28 def self.delegate(method_name) define_method(method_name) { api.send(method_name) } end |
.find(object_type, field) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cloud_runner/digital_ocean/api.rb', line 11 def self.find(object_type, field) define_method("all_#{object_type}s") do method = "#{object_type}s" api.send(method).list.send(method) end define_method("find_#{object_type}_by_#{field}") do |value| send("all_#{object_type}s").detect do |object| object.send(field) == value end end end |