class AWS::EC2::Tag

Represents an EC2 tag. @attr [String] value The tag value.

Attributes

key[R]

@return [String] The name of this tag.

name[R]

@return [String] The name of this tag.

resource[R]

@return [Object] The EC2 resource this tag belongs to.

Public Class Methods

new(resource, key, options = {}) click to toggle source

@param [String] key The name of the tag @param [Hash] options @option options [String] :value (”) The optional value of the tag.

# File lib/aws/ec2/tag.rb, line 24
def initialize resource, key, options = {}
  @resource = resource
  @key = key.to_s
  super
end

Public Instance Methods

delete(value = nil) click to toggle source

Deletes this tag. @return [nil]

# File lib/aws/ec2/tag.rb, line 46
def delete(value = nil)
  tag_opts = { :key => key }
  tag_opts[:value] = value if value
  client.delete_tags(:resources => [resource.id], :tags => [tag_opts])
  nil
end
inspect() click to toggle source

@private

# File lib/aws/ec2/tag.rb, line 54
def inspect
  "<#{self.class}:#{local_cache_key}>"
end
local_cache_key() click to toggle source

@private

# File lib/aws/ec2/tag.rb, line 59
def local_cache_key
  response_index_key
end

Protected Instance Methods

get_resource(attr) click to toggle source
# File lib/aws/ec2/tag.rb, line 71
def get_resource attr
  client.describe_tags(:filters => [
    { :name => "key", :values => [key] },
    { :name => "resource-type", :values => [resource.tagging_resource_type] },
    { :name => "resource-id", :values => [resource.send(:__resource_id__)] }
  ])
end