Class: Colombo::Droplets

Inherits:
Container show all
Defined in:
lib/colombo/droplets.rb

Instance Method Summary collapse

Methods inherited from Container

#find, #method_missing, #run_find_by_attr

Constructor Details

#initialize(client) ⇒ Droplets

Returns a new instance of Droplets.



8
9
10
11
12
13
14
15
# File 'lib/colombo/droplets.rb', line 8

def initialize(client)
  @client = client
  @client.request(:get, '/droplets/', {}) do |response|
     response['droplets'].each do |droplet|
        self << Droplet.new(@client, droplet)
     end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Colombo::Container

Instance Method Details

#create(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/colombo/droplets.rb', line 17

def create(options={})

 [:name,:size_id, :image_id,:region_id].each do |key|
    raise "Required `#{key}` attribute" if not options.include?( key )
  end

  if options[:ssh_keys]
    options[:ssh_keys] = options[:ssh_keys].join(',')
  end

  @client.request(:get, '/droplets/new', options) do |response|
    puts response
  end

end