1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

working _dump/_load, make connection/connection= public

This commit is contained in:
Wesley Beary 2009-11-21 13:46:46 -08:00
parent ce2ae970e9
commit 9e87d99a17
2 changed files with 32 additions and 16 deletions

View file

@ -1,6 +1,10 @@
module Fog
class Collection < Array
def self._load(marhsalled)
new(Marshal.load(marshalled))
end
def self.attribute(name, other_names = [])
class_eval <<-EOS, __FILE__, __LINE__
attr_accessor :#{name}
@ -24,6 +28,10 @@ module Fog
@attributes ||= []
end
def _dump
Marshal.dump(attributes)
end
def attributes
attributes = {}
for attribute in self.class.attributes
@ -32,6 +40,14 @@ module Fog
attributes
end
def connection=(new_connection)
@connection = new_connection
end
def connection
@connection
end
def create(attributes = {})
object = new(attributes)
object.save
@ -85,14 +101,6 @@ module Fog
private
def connection=(new_connection)
@connection = new_connection
end
def connection
@connection
end
def remap_attributes(attributes, mapping)
for key, value in mapping
if attributes.key?(key)

View file

@ -1,6 +1,10 @@
module Fog
class Model
def self._load(marshalled)
new(Marshal.load(marshalled))
end
def self.attribute(name, other_names = [])
class_eval <<-EOS, __FILE__, __LINE__
attr_accessor :#{name}
@ -25,6 +29,10 @@ module Fog
@attributes ||= []
end
def _dump
Marshal.dump(attributes)
end
def attributes
attributes = {}
for attribute in self.class.attributes
@ -37,6 +45,14 @@ module Fog
@collection
end
def connection=(new_connection)
@connection = new_connection
end
def connection
@connection
end
def identity
send(self.class.instance_variable_get('@identity'))
end
@ -79,14 +95,6 @@ module Fog
@collection = new_collection
end
def connection=(new_connection)
@connection = new_connection
end
def connection
@connection
end
def remap_attributes(attributes, mapping)
for key, value in mapping
if attributes.key?(key)