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

make more abstract reference to object identity, move reload to base class

This commit is contained in:
Wesley Beary 2009-10-23 10:27:23 -07:00
parent e3e826ad69
commit 5affe817f9
3 changed files with 18 additions and 12 deletions

View file

@ -4,8 +4,9 @@ module Fog
class Bucket < Fog::Model
identity :name, 'Name'
attribute :creation_date, 'CreationDate'
attribute :name, 'Name'
attribute :owner
def destroy
@ -43,11 +44,6 @@ module Fog
@payer = new_payer
end
def reload
new_attributes = collection.get(@name).attributes
merge_attributes(new_attributes)
end
def save
options = {}
if @location

View file

@ -4,11 +4,12 @@ module Fog
class Object < Fog::Model
identity :key, 'Key'
attribute :body
attribute :content_length, 'Content-Length'
attribute :content_type, 'Content-Type'
attribute :etag, ['Etag', 'ETag']
attribute :key, 'Key'
attribute :last_modified, ['Last-Modified', 'LastModified']
attribute :owner
attribute :size, 'Size'
@ -37,11 +38,6 @@ module Fog
true
end
def reload
new_attributes = collection.get(@key).attributes
merge_attributes(new_attributes)
end
def save(options = {})
data = connection.put_object(bucket.name, @key, @body, options)
@etag = data.headers['ETag']

View file

@ -11,6 +11,11 @@ module Fog
end
end
def self.identity(name, other_names = [])
@identity = name
self.attribute(name, other_names)
end
def self.aliases
@aliases ||= {}
end
@ -19,6 +24,10 @@ module Fog
@attributes ||= []
end
def identity
send(self.class.instance_variable_get('@identity'))
end
def initialize(new_attributes = {})
merge_attributes(new_attributes)
end
@ -54,6 +63,11 @@ module Fog
self
end
def reload
new_attributes = collection.get(identity).attributes
merge_attributes(new_attributes)
end
private
def collection=(new_collection)