Method: Inspec::Resources::AzureResourceBase#create_tag_methods

Defined in:
lib/resources/azure/azure_backend.rb

#create_tag_methodsObject

It is necessary to be able to test the tags of a resource. It is possible to say of the resource has tags or not, and it is possible to check that the tags include a specific tag However the value is not accessible, this function creates methods for all the tags that are available.

The format of the method name is ‘<TAG_NAME>_tag’ and will return the value of that tag

Disabling rubopcop check. If this is set as a normal if..then..end statement there is a violation stating it should use a guard. When using a guard it throws this error

Author:

  • Russell Seymour



154
155
156
157
158
159
160
161
162
163
164
# File 'lib/resources/azure/azure_backend.rb', line 154

def create_tag_methods
  # Iterate around the items of the tags and create the necessary access methods
  if defined?(tags.item)
    tags.item.each do |name, value|
      method_name = format("%s_tag", name)
      define_singleton_method method_name do
        value
      end
    end
  end
end