2009-08-02 16:37:54 -07:00
|
|
|
module Fog
|
2009-08-12 22:48:17 -07:00
|
|
|
class Collection
|
2009-08-02 16:37:54 -07:00
|
|
|
|
|
|
|
def initialize(attributes = {})
|
2009-08-04 20:09:08 -07:00
|
|
|
update_attributes(attributes)
|
2009-08-02 16:37:54 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
data = "#<#{self.class.name}"
|
|
|
|
for attribute in (self.instance_variables - ['@connection'])
|
|
|
|
data << " #{attribute}=#{send(attribute[1..-1].to_sym).inspect}"
|
|
|
|
end
|
|
|
|
data << "["
|
|
|
|
self.each do |element|
|
|
|
|
data << "#{element.inspect}, "
|
|
|
|
end
|
|
|
|
data = data[0..-3]
|
|
|
|
data << "]>"
|
|
|
|
end
|
|
|
|
|
2009-08-04 20:09:08 -07:00
|
|
|
def update_attributes(attributes = {})
|
|
|
|
for key, value in attributes
|
|
|
|
send(:"#{key}=", value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-08-02 16:37:54 -07:00
|
|
|
private
|
|
|
|
|
|
|
|
def connection=(new_connection)
|
|
|
|
@connection = new_connection
|
|
|
|
end
|
|
|
|
|
|
|
|
def connection
|
|
|
|
@connection
|
|
|
|
end
|
|
|
|
|
2009-08-04 10:51:54 -07:00
|
|
|
def remap_attributes(attributes, mapping)
|
|
|
|
for key, value in mapping
|
|
|
|
if attributes[key]
|
|
|
|
attributes[value] = attributes.delete(key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-08-02 16:37:54 -07:00
|
|
|
end
|
|
|
|
end
|