Module: RightScale::Api::McTaggable

Includes:
Taggable
Included in:
McDeployment, McInstance, McMultiCloudImage, McServer, McServerArray, McServerTemplate, McVolume, McVolumeSnapshot
Defined in:
lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb

Instance Method Summary collapse

Methods included from Taggable

#clear_tags, #get_info_tags, #get_tags_by_namespace, #remove_info_tags, #remove_tags_by_namespace, #set_info_tags, #set_tags_by_namespace, #set_tags_to

Instance Method Details

#add_tags(*args) ⇒ Object



31
32
33
34
35
# File 'lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb', line 31

def add_tags(*args)
  return false if args.empty?
  McTag.set(self.href, args.uniq)
  self.tags(true)
end

#remove_tags(*args) ⇒ Object



37
38
39
40
41
42
# File 'lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb', line 37

def remove_tags(*args)
  return false if args.empty?
  McTag.unset(self.href, args.uniq)
  @params["tags"] -= args
  self.tags(true)
end

#tags(reload = false) ⇒ Object



44
45
46
47
48
49
# File 'lib/rest_connection/rightscale/rightscale_api_mc_taggable.rb', line 44

def tags(reload=false)
  @params["tags"] ||= []
  @params["tags"].map! { |item| item.is_a?(Hash) ? item["name"] : item }
  @params["tags"].deep_merge!(McTag.search_by_href(self.href).first["tags"].map { |hsh| hsh["name"] }) if reload or @params["tags"].empty?
  @params["tags"]
end