2009-08-02 23:37:54 +00:00
|
|
|
module Fog
|
|
|
|
class Model
|
|
|
|
|
2009-08-30 21:14:11 +00:00
|
|
|
def initialize(new_attributes = {})
|
|
|
|
merge_attributes(new_attributes)
|
2009-08-02 23:37:54 +00: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 << ">"
|
|
|
|
end
|
|
|
|
|
2009-08-30 21:14:11 +00:00
|
|
|
def merge_attributes(new_attributes = {})
|
|
|
|
for key, value in new_attributes
|
2009-08-05 03:09:08 +00:00
|
|
|
send(:"#{key}=", value)
|
|
|
|
end
|
2009-08-06 05:55:09 +00:00
|
|
|
self
|
2009-08-05 03:09:08 +00:00
|
|
|
end
|
|
|
|
|
2009-08-02 23:37:54 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def connection=(new_connection)
|
|
|
|
@connection = new_connection
|
|
|
|
end
|
|
|
|
|
|
|
|
def connection
|
|
|
|
@connection
|
|
|
|
end
|
|
|
|
|
2009-08-04 17:51:54 +00:00
|
|
|
def remap_attributes(attributes, mapping)
|
|
|
|
for key, value in mapping
|
2009-08-18 01:34:44 +00:00
|
|
|
if attributes.key?(key)
|
2009-08-04 17:51:54 +00:00
|
|
|
attributes[value] = attributes.delete(key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-08-02 23:37:54 +00:00
|
|
|
end
|
|
|
|
end
|