Module: RAWS::S3::Model::ClassMethods

Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/raws/s3/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucket_nameObject

Returns the value of attribute bucket_name.



22
23
24
# File 'lib/raws/s3/model.rb', line 22

def bucket_name
  @bucket_name
end

Instance Method Details

#bucketObject



37
38
39
# File 'lib/raws/s3/model.rb', line 37

def bucket
  RAWS::S3[bucket_name]
end

#filter(query = {}) ⇒ Object Also known as: all, each



41
42
43
44
45
# File 'lib/raws/s3/model.rb', line 41

def filter(query={})
  bucket.filter(query).map do |contents|
    self.new(contents['Key'])
  end
end

#find(key) ⇒ Object



49
50
51
# File 'lib/raws/s3/model.rb', line 49

def find(key)
  self.new key, head(key)
end

#head_object(key) ⇒ Object Also known as: head



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/raws/s3/model.rb', line 24

def head_object(key)
  begin
    bucket.head_object(key).header
  rescue => e
    if e.response.code == 404
      {}
    else
      raise e
    end
  end
end