Class: AzureResourceProbe
- Inherits:
-
Object
- Object
- AzureResourceProbe
- Defined in:
- lib/resources/azure/azure_backend.rb
Overview
Class object that is created for each element that is returned by Azure. This is what is interogated by Inspec. If they are nested hashes, then this results in nested AzureResourceProbe objects.
For example, if the following was seen in an Azure Resource
properties -> storageProfile -> imageReference
Would result in the following nestec classes
AzureResource -> AzureResourceProbe -> AzureResourceProbe
The methods for each of the classes are dynamically defined at run time and will match the items that are retrieved from Azure. See the ‘test/integration/verify/controls’ for examples
This class will not be called externally
Instance Attribute Summary collapse
- #count ⇒ Object readonly
- #item ⇒ Object readonly
- #location ⇒ Object readonly
- #name ⇒ Object readonly
-
#string ⇒ Object
readonly
name Name of the Azure resource.
- #type ⇒ Object readonly
Instance Method Summary collapse
-
#camel_case(data) ⇒ Object
Give a sting like ‘computer_name` return the camelCase version, e.g.
-
#include?(key) ⇒ Boolean
Allows resources to respond to the include test This means that things like tags can be checked for and then their value tested.
-
#initialize(item) ⇒ Object
constructor
Initialize method for the class.
Constructor Details
#initialize(item) ⇒ Object
Initialize method for the class. Accepts an item, be it a scalar value, hash or Azure object It will then create the necessary dynamic methods so that they can be called in the tests This is accomplished by call the AzureResourceDynamicMethods
342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/resources/azure/azure_backend.rb', line 342 def initialize(item) dm = AzureResourceDynamicMethods.new dm.create_methods(self, item) # Set the item as a property on the class # This is so that it is possible to interrogate what has been added to the class and isolate them from # the standard methods that a Ruby class has. # This used for checking Tags on a resource for example # It also allows direct access if so required @item = item # Set how many items have been set @count = item.length end |
Instance Attribute Details
#count ⇒ Object (readonly)
333 334 335 |
# File 'lib/resources/azure/azure_backend.rb', line 333 def count @count end |
#item ⇒ Object (readonly)
333 334 335 |
# File 'lib/resources/azure/azure_backend.rb', line 333 def item @item end |
#location ⇒ Object (readonly)
333 334 335 |
# File 'lib/resources/azure/azure_backend.rb', line 333 def location @location end |
#name ⇒ Object (readonly)
333 334 335 |
# File 'lib/resources/azure/azure_backend.rb', line 333 def name @name end |
#string ⇒ Object (readonly)
name Name of the Azure resource
332 333 334 |
# File 'lib/resources/azure/azure_backend.rb', line 332 def string @string end |
#type ⇒ Object (readonly)
333 334 335 |
# File 'lib/resources/azure/azure_backend.rb', line 333 def type @type end |
Instance Method Details
#camel_case(data) ⇒ Object
Give a sting like ‘computer_name` return the camelCase version, e.g. computerName
373 374 375 376 377 378 |
# File 'lib/resources/azure/azure_backend.rb', line 373 def camel_case(data) camel_case_data = data.split("_").inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join # Ensure that gb (as in gigabytes) is uppercased camel_case_data.gsub(/[gb]/, &:upcase) end |
#include?(key) ⇒ Boolean
Allows resources to respond to the include test This means that things like tags can be checked for and then their value tested
363 364 365 |
# File 'lib/resources/azure/azure_backend.rb', line 363 def include?(key) @item.key?(key) end |