Method: Chef::Resource#identity

Defined in:
lib/chef/resource.rb

#identityObject, Hash<Symbol,Object>

The value of the identity of this resource.

  • If there are no identity properties on the resource, name is returned.

  • If there is exactly one identity property on the resource, it is returned.

  • If there are more than one, they are returned in a hash.

Returns:

  • The identity of this resource.



526
527
528
529
530
531
532
533
534
535
# File 'lib/chef/resource.rb', line 526

def identity
  result = {}
  identity_properties = self.class.identity_properties
  identity_properties.each do |property|
    result[property.name] = send(property.name)
  end
  return result.values.first if identity_properties.size == 1

  result
end