Class: AWS::S3::BucketTagCollection
- Inherits:
-
Object
- Object
- AWS::S3::BucketTagCollection
- Defined in:
- lib/aws/s3/bucket_tag_collection.rb
Overview
Manages tags for a single S3 Bucket.
Instance Attribute Summary collapse
- #bucket ⇒ Bucket readonly
Instance Method Summary collapse
-
#[](key) ⇒ String?
Returns the tag for the given key.
- #[]=(key, value) ⇒ Object
-
#clear ⇒ nil
Removes all tags from the bucket.
-
#eql?(other) ⇒ Boolean
(also: #==)
Returns
true
if the tags for this bucket match the passed hash. -
#initialize(bucket, options = {}) ⇒ BucketTagCollection
constructor
A new instance of BucketTagCollection.
- #set(tags) ⇒ nil
- #to_h ⇒ Hash (also: #to_hash)
Constructor Details
#initialize(bucket, options = {}) ⇒ BucketTagCollection
Returns a new instance of BucketTagCollection.
43 44 45 46 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 43 def initialize bucket, = {} @bucket = bucket super end |
Instance Attribute Details
#bucket ⇒ Bucket (readonly)
49 50 51 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 49 def bucket @bucket end |
Instance Method Details
#[](key) ⇒ String?
Returns the tag for the given key. If there
Returns nil
if the key does not exist.
54 55 56 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 54 def [] key self.to_h[key] end |
#[]=(key, value) ⇒ Object
60 61 62 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 60 def []= key, value self.set(self.to_h.merge(key => value)) end |
#clear ⇒ nil
Removes all tags from the bucket.
83 84 85 86 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 83 def clear client.delete_bucket_tagging(:bucket_name => bucket.name) nil end |
#eql?(other) ⇒ Boolean Also known as: ==
Returns true
if the tags for this bucket match
the passed hash.
99 100 101 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 99 def eql? other self.to_h == other end |
#set(tags) ⇒ nil
66 67 68 69 70 71 72 73 |
# File 'lib/aws/s3/bucket_tag_collection.rb', line 66 def set if .nil? or .empty? self.clear else client.put_bucket_tagging(:bucket_name => bucket.name, :tags => ) end nil end |