Class: Fog::AWS::S3::Objects

Inherits:
Collection show all
Defined in:
lib/fog/aws/models/s3/objects.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Collection

#inspect, #update_attributes

Constructor Details

#initialize(attributes = {}) ⇒ Objects

Returns a new instance of Objects.



12
13
14
15
16
17
18
19
20
# File 'lib/fog/aws/models/s3/objects.rb', line 12

def initialize(attributes = {})
  remap_attributes(attributes, {
    'IsTruncated' => :is_truncated,
    'Marker' => :marker,
    'MaxKeys' => :max_keys,
    'Prefix' => :prefix
  })
  super
end

Instance Attribute Details

#is_truncatedObject

Returns the value of attribute is_truncated.



7
8
9
# File 'lib/fog/aws/models/s3/objects.rb', line 7

def is_truncated
  @is_truncated
end

#markerObject

Returns the value of attribute marker.



7
8
9
# File 'lib/fog/aws/models/s3/objects.rb', line 7

def marker
  @marker
end

#max_keysObject

Returns the value of attribute max_keys.



7
8
9
# File 'lib/fog/aws/models/s3/objects.rb', line 7

def max_keys
  @max_keys
end

#prefixObject

Returns the value of attribute prefix.



7
8
9
# File 'lib/fog/aws/models/s3/objects.rb', line 7

def prefix
  @prefix
end

Instance Method Details

#all(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/aws/models/s3/objects.rb', line 22

def all(options = {})
  data = connection.get_bucket(bucket.name, options).body
  objects_data = {}
  for key, value in data
    if ['IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key)
      objects_data[key] = value
    end
  end
  objects = Fog::AWS::S3::Objects.new({
    :bucket       => bucket,
    :connection   => connection
  }.merge!(objects_data))
  data['Contents'].each do |object|
    owner = Fog::AWS::S3::Owner.new(object.delete('Owner').merge!(:connection => connection))
    objects << Fog::AWS::S3::Object.new({
      :bucket         => bucket,
      :connection     => connection,
      :owner          => owner
    }.merge!(object))
  end
  objects
end

#create(attributes = {}) ⇒ Object



45
46
47
48
49
# File 'lib/fog/aws/models/s3/objects.rb', line 45

def create(attributes = {})
  object = new(attributes)
  object.save
  object
end

#new(attributes = {}) ⇒ Object



51
52
53
54
55
56
# File 'lib/fog/aws/models/s3/objects.rb', line 51

def new(attributes = {})
  Fog::AWS::S3::Object.new({
    :bucket     => bucket,
    :connection => connection
  }.merge!(attributes))
end