Class: ActiveAws::TagSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/active_aws/tag_spec.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_type, tags) ⇒ TagSpec

Returns a new instance of TagSpec.



17
18
19
20
# File 'lib/active_aws/tag_spec.rb', line 17

def initialize( resource_type, tags )
  @resource_type = resource_type
  @tags = tags
end

Instance Attribute Details

#resource_typeObject (readonly)

Returns the value of attribute resource_type.



16
17
18
# File 'lib/active_aws/tag_spec.rb', line 16

def resource_type
  @resource_type
end

#tagsObject (readonly)

Returns the value of attribute tags.



16
17
18
# File 'lib/active_aws/tag_spec.rb', line 16

def tags
  @tags
end

Class Method Details

.parse(tag_specifications) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/active_aws/tag_spec.rb', line 5

def parse( tag_specifications )
  tag_specifications.map do |spec|
    spec = spec.deep_symbolize_keys
    self.new(
      spec[:resource_type], 
      spec[:tags].map{|t| [t[:key], t[:value]]}.to_h 
    )
  end
end

Instance Method Details

#add_tag!(key, value) ⇒ Object



22
23
24
# File 'lib/active_aws/tag_spec.rb', line 22

def add_tag!( key, value )
  @tags[key.to_s] = value
end

#merge(extra_tags) ⇒ Object



26
27
28
# File 'lib/active_aws/tag_spec.rb', line 26

def merge( extra_tags )
  self.class.new( resource_type, tags.merge(extra_tags) )
end

#to_paramObject



30
31
32
33
34
35
# File 'lib/active_aws/tag_spec.rb', line 30

def to_param
  {
    resource_type: resource_type,
    tags: tags.map{|k,v| { key: k, value: v}}
  }
end