Class: AssetCloud::BucketChain
- Inherits:
-
Bucket
- Object
- Bucket
- AssetCloud::BucketChain
show all
- Defined in:
- lib/asset_cloud/buckets/bucket_chain.rb
Instance Attribute Summary
Attributes inherited from Bucket
#cloud, #name
Class Method Summary
collapse
-
.chain(*klasses) ⇒ Object
returns a new Bucket class which writes to each given Bucket but only uses the first one for reading.
Instance Method Summary
collapse
Methods inherited from Bucket
#initialize, #versioned?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
52
53
54
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 52
def method_missing(sym, *args)
first_possible_bucket { |b| b.send(sym, *args) }
end
|
Class Method Details
.chain(*klasses) ⇒ Object
returns a new Bucket class which writes to each given Bucket but only uses the first one for reading
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 8
def chain(*klasses)
Class.new(self) do
attr_reader :chained_buckets
define_method "initialize" do |cloud, name|
super(cloud, name)
@chained_buckets = klasses.map { |klass| klass.new(cloud, name) }
end
end
end
|
Instance Method Details
#delete(key) ⇒ Object
44
45
46
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 44
def delete(key)
every_bucket_with_transaction_on_key(key) { |b| b.delete(key) }
end
|
#ls(key = nil) ⇒ Object
20
21
22
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 20
def ls(key = nil)
first_possible_bucket { |b| b.ls(key) }
end
|
#read(key) ⇒ Object
24
25
26
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 24
def read(key)
first_possible_bucket { |b| b.read(key) }
end
|
#read_version(key, version) ⇒ Object
32
33
34
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 32
def read_version(key, version)
first_possible_bucket { |b| b.read_version(key, version) }
end
|
#respond_to_missing?(sym) ⇒ Boolean
48
49
50
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 48
def respond_to_missing?(sym, *)
@chained_buckets.any? { |b| b.respond_to?(sym) }
end
|
#stat(key = nil) ⇒ Object
28
29
30
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 28
def stat(key = nil)
first_possible_bucket { |b| b.stat(key) }
end
|
#versions(key) ⇒ Object
36
37
38
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 36
def versions(key)
first_possible_bucket { |b| b.versions(key) }
end
|
#write(key, data) ⇒ Object
40
41
42
|
# File 'lib/asset_cloud/buckets/bucket_chain.rb', line 40
def write(key, data)
every_bucket_with_transaction_on_key(key) { |b| b.write(key, data) }
end
|