class Inspec::Resources::AzureResourceGroup

def method_missing(method_id)

Parameters:
  • method_id (Symbol) -- The name of the method that was called

Other tags:
    Author: - Russell Seymour
def method_missing(method_id)
  # Determine the mapping_key based on the method_id
  mapping_key = method_id.to_s.chomp("_count").to_sym
  if mapping.key?(mapping_key)
    # based on the method id get the
    namespace, type_name = mapping[mapping_key].split(/\./)
    # check that the type_name is defined, if not return 0
    if send(namespace).methods.include?(type_name.to_sym)
      # return the count for the method id
      send(namespace).send(type_name)
    else
      0
    end
  else
    msg = format("undefined method `%s` for %s", method_id, self.class)
    raise NoMethodError, msg
  end
end