class AWS::S3::BucketTagCollection
bucket.tags.clear
@example Removing all tags
#=> { ‘key’ => ‘value’, … }
bucket.tags.to_h
@example Getting all tags
#=> ‘value’
bucket.tags[‘key’]
@example Getting a tag.<br><br>bucket.tags = ‘value’
@example Setting a tag.
Manages tags for a single S3 {Bucket}.
def [] key
-
(String, nil)
- Returns the tag for the given key. If there
Parameters:
-
key
(String
) --
def [] key self.to_h[key] end
def []= key, value
-
value
(String
) -- -
key
(String
) --
def []= key, value self.set(self.to_h.merge(key => value)) end
def clear
-
(nil)
-
def clear client.delete_bucket_tagging(:bucket_name => bucket.name) nil end
def eql? other
-
(Boolean)
- Returns `true` if the tags for this bucket match
Parameters:
-
other
(Hash
) --
def eql? other self.to_h == other end
def initialize bucket, options = {}
-
options
(Hash
) -- -
bucket
(Bucket
) --
def initialize bucket, options = {} @bucket = bucket super end
def inspect
- Api: - private
def inspect self.to_h.inspect end
def set tags
-
(nil)
-
Parameters:
-
tags
(Hash
) -- A hash of tag keys and values.
def set tags if tags.nil? or tags.empty? self.clear else client.put_bucket_tagging(:bucket_name => bucket.name, :tags => tags) end nil end
def to_h
-
(Hash)
-
def to_h client.get_bucket_tagging(:bucket_name => bucket.name).data[:tags] rescue AWS::S3::Errors::NoSuchTagSet {} end