Sha256: 1b8a43e9eb0a5388444743281346fe1f9a30a98fb3df582247735d964c3eecc1
Contents?: true
Size: 955 Bytes
Versions: 2
Compression:
Stored size: 955 Bytes
Contents
require "digital_ocean" require "cloud_runner/digital_ocean/base" module CloudRunner::DigitalOcean class Api def initialize(client_id, api_key) @client_id = client_id @api_key = api_key end 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 find :region, :name find :size, :name find :image, :name def self.delegate(method_name) define_method(method_name) { api.send(method_name) } end delegate :ssh_keys delegate :droplets private def api @api ||= ::DigitalOcean::API.new( :client_id => @client_id, :api_key => @api_key, ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cloud_runner-0.0.2 | lib/cloud_runner/digital_ocean/api.rb |
cloud_runner-0.0.1 | lib/cloud_runner/digital_ocean/api.rb |