mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fixes around collections
This commit is contained in:
parent
ff2f32d342
commit
1f41499e64
5 changed files with 16 additions and 10 deletions
|
@ -11,7 +11,7 @@ module Fog
|
||||||
def all
|
def all
|
||||||
data = connection.get_service.body
|
data = connection.get_service.body
|
||||||
owner = Fog::AWS::S3::Owner.new(data.delete('Owner').merge!(:connection => connection))
|
owner = Fog::AWS::S3::Owner.new(data.delete('Owner').merge!(:connection => connection))
|
||||||
buckets = []
|
buckets = Fog::AWS::S3::Buckets.new
|
||||||
data['Buckets'].each do |bucket|
|
data['Buckets'].each do |bucket|
|
||||||
buckets << Fog::AWS::S3::Bucket.new({
|
buckets << Fog::AWS::S3::Bucket.new({
|
||||||
:connection => connection,
|
:connection => connection,
|
||||||
|
|
|
@ -122,7 +122,7 @@ DATA
|
||||||
canonical_resource << "#{subdomain}/"
|
canonical_resource << "#{subdomain}/"
|
||||||
end
|
end
|
||||||
canonical_resource << "#{params[:path]}"
|
canonical_resource << "#{params[:path]}"
|
||||||
if ['acl', 'location', 'logging', 'torrent'].include?(params[:query])
|
if ['acl', 'location', 'logging', 'requestPayment', 'torrent'].include?(params[:query])
|
||||||
canonical_resource << "?#{params[:query]}"
|
canonical_resource << "?#{params[:query]}"
|
||||||
end
|
end
|
||||||
string_to_sign << "#{canonical_resource}"
|
string_to_sign << "#{canonical_resource}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Fog
|
module Fog
|
||||||
class Collection
|
class Collection < Array
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
update_attributes(attributes)
|
update_attributes(attributes)
|
||||||
|
@ -10,11 +10,11 @@ module Fog
|
||||||
for attribute in (self.instance_variables - ['@connection'])
|
for attribute in (self.instance_variables - ['@connection'])
|
||||||
data << " #{attribute}=#{send(attribute[1..-1].to_sym).inspect}"
|
data << " #{attribute}=#{send(attribute[1..-1].to_sym).inspect}"
|
||||||
end
|
end
|
||||||
data << "["
|
data << " ["
|
||||||
self.each do |element|
|
for item in self
|
||||||
data << "#{element.inspect}, "
|
data << "#{item.inspect},"
|
||||||
end
|
end
|
||||||
data = data[0..-3]
|
data.chomp!
|
||||||
data << "]>"
|
data << "]>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ module Fog
|
||||||
for key, value in attributes
|
for key, value in attributes
|
||||||
send(:"#{key}=", value)
|
send(:"#{key}=", value)
|
||||||
end
|
end
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -34,9 +35,13 @@ module Fog
|
||||||
@connection
|
@connection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_record?
|
||||||
|
!defined?(@new_record) || @new_record
|
||||||
|
end
|
||||||
|
|
||||||
def remap_attributes(attributes, mapping)
|
def remap_attributes(attributes, mapping)
|
||||||
for key, value in mapping
|
for key, value in mapping
|
||||||
if attributes[key]
|
if attributes.key?(key)
|
||||||
attributes[value] = attributes.delete(key)
|
attributes[value] = attributes.delete(key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Fog
|
||||||
|
|
||||||
def remap_attributes(attributes, mapping)
|
def remap_attributes(attributes, mapping)
|
||||||
for key, value in mapping
|
for key, value in mapping
|
||||||
if mapping[key]
|
if attributes.key?(key)
|
||||||
attributes[value] = attributes.delete(key)
|
attributes[value] = attributes.delete(key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,8 +23,9 @@ describe 'S3.buckets' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should push bucket down into objects" do
|
it "should push bucket down into objects" do
|
||||||
p @bucket = @s3.buckets.create(:name => 'fogbucketspaymenttest')
|
p @bucket = @s3.buckets.create(:name => 'fogbucketsobjectstest')
|
||||||
p @bucket.objects.new(:key => 'object')
|
p @bucket.objects.new(:key => 'object')
|
||||||
|
p @bucket.objects.all
|
||||||
p @bucket.delete
|
p @bucket.delete
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue