Class: Fog::AWS::S3::Buckets
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::S3::Buckets
- Defined in:
- lib/fog/aws/models/s3/buckets.rb
Instance Method Summary collapse
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #initialize, #inspect, #merge_attributes, model, #model, #new, #reload
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fog/aws/models/s3/buckets.rb', line 13 def all if @loaded clear end @loaded = true data = connection.get_service.body data['Buckets'].each do |bucket| self << new(bucket) end self end |
#get(name, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/aws/models/s3/buckets.rb', line 25 def get(name, = {}) remap_attributes(, { :max_keys => 'max-keys', }) data = connection.get_bucket(name, ).body bucket = new(:name => data['Name']) = {} for key, value in data if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key) [key] = value end end bucket.objects.merge_attributes() bucket.objects.instance_variable_set(:@loaded, true) data['Contents'].each do |object| bucket.objects << bucket.objects.new(object) end bucket rescue Excon::Errors::NotFound nil end |