Class: FakeS3::Bucket
- Inherits:
-
Object
- Object
- FakeS3::Bucket
- Defined in:
- lib/fakes3/bucket.rb
Instance Attribute Summary collapse
-
#creation_date ⇒ Object
Returns the value of attribute creation_date.
-
#name ⇒ Object
Returns the value of attribute name.
-
#objects ⇒ Object
Returns the value of attribute objects.
Instance Method Summary collapse
- #add(object) ⇒ Object
- #find(object_name) ⇒ Object
-
#initialize(name, creation_date, objects) ⇒ Bucket
constructor
A new instance of Bucket.
- #query_for_range(options) ⇒ Object
- #remove(object) ⇒ Object
Constructor Details
#initialize(name, creation_date, objects) ⇒ Bucket
Returns a new instance of Bucket.
10 11 12 13 14 15 16 17 18 |
# File 'lib/fakes3/bucket.rb', line 10 def initialize(name,creation_date,objects) @name = name @creation_date = creation_date @objects = SortedObjectList.new objects.each do |obj| @objects.add(obj) end @mutex = Mutex.new end |
Instance Attribute Details
#creation_date ⇒ Object
Returns the value of attribute creation_date.
8 9 10 |
# File 'lib/fakes3/bucket.rb', line 8 def creation_date @creation_date end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/fakes3/bucket.rb', line 8 def name @name end |
#objects ⇒ Object
Returns the value of attribute objects.
8 9 10 |
# File 'lib/fakes3/bucket.rb', line 8 def objects @objects end |
Instance Method Details
#add(object) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/fakes3/bucket.rb', line 26 def add(object) # Unfortunately have to synchronize here since the our SortedObjectList # not thread safe. Probably can get finer granularity if performance is # important @mutex.synchronize do @objects.add(object) end end |
#find(object_name) ⇒ Object
20 21 22 23 24 |
# File 'lib/fakes3/bucket.rb', line 20 def find(object_name) @mutex.synchronize do @objects.find(object_name) end end |
#query_for_range(options) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fakes3/bucket.rb', line 41 def query_for_range() marker = [:marker] prefix = [:prefix] max_keys = [:max_keys] || 1000 delimiter = [:delimiter] match_set = nil @mutex.synchronize do match_set = @objects.list() end bq = BucketQuery.new bq.bucket = self bq.marker = marker bq.prefix = prefix bq.max_keys = max_keys bq.delimiter = delimiter bq.matches = match_set.matches bq.is_truncated = match_set.is_truncated bq.common_prefixes = match_set.common_prefixes return bq end |
#remove(object) ⇒ Object
35 36 37 38 39 |
# File 'lib/fakes3/bucket.rb', line 35 def remove(object) @mutex.synchronize do @objects.remove(object) end end |