class FakeS3::Bucket
Attributes
creation_date[RW]
name[RW]
objects[RW]
Public Class Methods
new(name,creation_date,objects)
click to toggle source
# 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
Public Instance Methods
add(object)
click to toggle source
# 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)
click to toggle source
# File lib/fakes3/bucket.rb, line 20 def find(object_name) @mutex.synchronize do @objects.find(object_name) end end
query_for_range(options)
click to toggle source
# File lib/fakes3/bucket.rb, line 41 def query_for_range(options) marker = options[:marker] prefix = options[:prefix] max_keys = options[:max_keys] || 1000 delimiter = options[:delimiter] match_set = nil @mutex.synchronize do match_set = @objects.list(options) 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)
click to toggle source
# File lib/fakes3/bucket.rb, line 35 def remove(object) @mutex.synchronize do @objects.remove(object) end end