mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
let models know about their collections
This commit is contained in:
parent
846d6279f7
commit
e32c247720
4 changed files with 48 additions and 14 deletions
|
@ -53,6 +53,16 @@ module Fog
|
|||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def buckets
|
||||
@buckets
|
||||
end
|
||||
|
||||
def buckets=(new_buckets)
|
||||
@buckets = new_buckets
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,6 +14,7 @@ module Fog
|
|||
buckets = Fog::AWS::S3::Buckets.new
|
||||
data['Buckets'].each do |bucket|
|
||||
buckets << Fog::AWS::S3::Bucket.new({
|
||||
:buckets => self
|
||||
:connection => connection,
|
||||
:owner => owner
|
||||
}.merge!(bucket))
|
||||
|
@ -28,7 +29,12 @@ module Fog
|
|||
end
|
||||
|
||||
def new(attributes = {})
|
||||
Fog::AWS::S3::Bucket.new(attributes.merge!(:connection => connection))
|
||||
Fog::AWS::S3::Bucket.new(
|
||||
attributes.merge!(
|
||||
:connection => connection,
|
||||
:buckets => self
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -61,6 +61,14 @@ module Fog
|
|||
@bucket = new_bucket
|
||||
end
|
||||
|
||||
def objects
|
||||
@objects
|
||||
end
|
||||
|
||||
def objects=(new_objects)
|
||||
@objects = new_objects
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,6 +20,12 @@ module Fog
|
|||
end
|
||||
|
||||
def all(options = {})
|
||||
remap_attributes(options, {
|
||||
:is_truncated => 'IsTruncated',
|
||||
:marker => 'Marker',
|
||||
:max_keys => 'MaxKeys',
|
||||
:prefix => 'Prefix'
|
||||
})
|
||||
data = connection.get_bucket(bucket.name, options).body
|
||||
objects_data = {}
|
||||
for key, value in data
|
||||
|
@ -36,6 +42,7 @@ module Fog
|
|||
objects << Fog::AWS::S3::Object.new({
|
||||
:bucket => bucket,
|
||||
:connection => connection,
|
||||
:objects => self,
|
||||
:owner => owner
|
||||
}.merge!(object))
|
||||
end
|
||||
|
@ -62,7 +69,8 @@ module Fog
|
|||
end
|
||||
Fog::AWS::S3::Object.new({
|
||||
:bucket => bucket,
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:objects => self
|
||||
}.merge!(object_data))
|
||||
end
|
||||
|
||||
|
@ -76,14 +84,16 @@ module Fog
|
|||
end
|
||||
Fog::AWS::S3::Object.new({
|
||||
:bucket => bucket,
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:objects => self
|
||||
}.merge!(object_data))
|
||||
end
|
||||
|
||||
def new(attributes = {})
|
||||
Fog::AWS::S3::Object.new({
|
||||
:bucket => bucket,
|
||||
:connection => connection
|
||||
:connection => connection,
|
||||
:objects => self
|
||||
}.merge!(attributes))
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue