Class: OmniStore::Storage::S3::Mountpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/omnistore/storage/s3/mountpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, bucket) ⇒ Mountpoint

Returns a new instance of Mountpoint.



7
8
9
10
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 7

def initialize(name, bucket)
  @name   = name
  @bucket = bucket
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



5
6
7
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 5

def bucket
  @bucket
end

Instance Method Details

#copy(src, dest, other = self, options = {}) ⇒ Object



51
52
53
54
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 51

def copy(src, dest, other = self, options = {})
  options[:bucket] = other.bucket
  bucket.objects[src].copy_to(dest, options)
end

#delete(key, options = {}) ⇒ Object



28
29
30
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 28

def delete(key, options = {})
  bucket.objects[key].delete(options)
end

#delete_if(key_prefix = nil, &block) ⇒ Object



32
33
34
35
36
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 32

def delete_if(key_prefix = nil, &block)
  bucket.objects.with_prefix(key_prefix).delete_if do |object|
    yield object.key
  end
end

#exist?(key) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 24

def exist?(key)
  bucket.objects[key].exists?
end

#move(src, dest, other = self, options = {}) ⇒ Object



46
47
48
49
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 46

def move(src, dest, other = self, options = {})
  options[:bucket_name] = other.bucket.name
  bucket.objects[src].move_to(dest, options)
end

#nameObject



12
13
14
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 12

def name
  @name
end

#read(key, options = {}, &block) ⇒ Object



38
39
40
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 38

def read(key, options = {}, &block)
  bucket.objects[key].read(options, &block)
end

#url(key = nil, options = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 16

def url(key = nil, options = {})
  if key
    bucket.objects[key].public_url(:secure => options[:secure] != false).to_s
  else
    bucket.url
  end
end

#write(key, options_or_data = nil, options = {}) ⇒ Object



42
43
44
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 42

def write(key, options_or_data = nil, options = {})
  bucket.objects[key].write(options_or_data, options)
end