Method: OneviewSDK::API200::StorageSystem#like?

Defined in:
lib/oneview-sdk/resource/api200/storage_system.rb

#like?(other) ⇒ Boolean

Note:

Does not check the client, logger, or api_version if another resource is passed in

Note:

Does not check the password in credentials

Check the equality of the data for the other resource with this resource.

Examples:

Compare to hash

myResource.like?(credentials: { username: ‘admin’, password: ‘secret’ })

myResource = OneviewSDK::Resource.new(client, { name: 'res1', description: 'example'}, 200)
myResource.like?(description: '') # returns false
myResource.like?(name: 'res1') # returns true

Parameters:

  • other (Hash, Resource)

    resource or hash to compare the key-value pairs with

Returns:

  • (Boolean)

    Whether or not the two objects are alike



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/oneview-sdk/resource/api200/storage_system.rb', line 104

def like?(other)
  if other.is_a? Hash
    other_copy = Marshal.load(Marshal.dump(other))
  else
    other_copy = other.dup
    other_copy.data = Marshal.load(Marshal.dump(other.data))
  end

  if other_copy['credentials']
    other_copy['credentials'].delete('password') rescue nil
    other_copy['credentials'].delete(:password) rescue nil
  elsif other_copy[:credentials]
    other_copy[:credentials].delete('password') rescue nil
    other_copy[:credentials].delete(:password) rescue nil
  end

  super(other_copy)
end