Class: OmniStore::Storage::S3::Mountpoint
- Inherits:
-
Object
- Object
- OmniStore::Storage::S3::Mountpoint
- Defined in:
- lib/omnistore/storage/s3/mountpoint.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
Instance Method Summary collapse
- #copy(src, dest, other = self, options = {}) ⇒ Object
- #delete(key, options = {}) ⇒ Object
- #delete_if(key_prefix = nil, &block) ⇒ Object
- #exist?(key) ⇒ Boolean
-
#initialize(name, bucket) ⇒ Mountpoint
constructor
A new instance of Mountpoint.
- #move(src, dest, other = self, options = {}) ⇒ Object
- #name ⇒ Object
- #read(key, options = {}, &block) ⇒ Object
- #url(key = nil, options = {}) ⇒ Object
- #write(key, options_or_data = nil, options = {}) ⇒ Object
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
#bucket ⇒ Object (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, = {}) [:bucket] = other.bucket bucket.objects[src].copy_to(dest, ) end |
#delete(key, options = {}) ⇒ Object
28 29 30 |
# File 'lib/omnistore/storage/s3/mountpoint.rb', line 28 def delete(key, = {}) bucket.objects[key].delete() 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
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, = {}) [:bucket_name] = other.bucket.name bucket.objects[src].move_to(dest, ) end |
#name ⇒ Object
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, = {}, &block) bucket.objects[key].read(, &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, = {}) if key bucket.objects[key].public_url(:secure => [: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, = nil, = {}) bucket.objects[key].write(, ) end |