1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/linode/models/compute/data_centers.rb

27 lines
707 B
Ruby
Raw Normal View History

2011-03-01 12:00:48 -05:00
require 'fog/core/collection'
require 'fog/linode/models/compute/data_center'
2011-03-01 12:00:48 -05:00
module Fog
module Compute
class Linode
2011-03-01 12:00:48 -05:00
class DataCenters < Fog::Collection
model Fog::Compute::Linode::DataCenter
2011-03-01 12:00:48 -05:00
def all
load datacenters
end
private
def datacenters(id=nil)
2011-03-01 16:37:27 -05:00
connection.avail_datacenters.body['DATA'].map { |datacenter| map_datacenter datacenter }
2011-03-01 12:00:48 -05:00
end
2011-03-01 16:37:27 -05:00
def map_datacenter(datacenter)
datacenter = datacenter.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v }
datacenter.merge! :id => datacenter[:datacenterid], :name => datacenter[:location]
2011-03-01 12:00:48 -05:00
end
end
end
end
end