lib/fog/vsphere/models/compute/volume.rb in fog-1.22.0 vs lib/fog/vsphere/models/compute/volume.rb in fog-1.22.1

- old
+ new

@@ -1,9 +1,8 @@ module Fog module Compute class Vsphere - class Volume < Fog::Model DISK_SIZE_TO_GB = 1048576 identity :id attribute :datastore @@ -47,10 +46,10 @@ def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :server_id, :size, :datastore if unit_number.nil? - used_unit_numbers = server.volumes.collect { |volume| volume.unit_number } + used_unit_numbers = server.volumes.map { |volume| volume.unit_number } max_unit_number = used_unit_numbers.max if max_unit_number > server.volumes.size # If the max ID exceeds the number of volumes, there must be a hole in the range. Find a hole and use it. self.unit_number = max_unit_number.times.to_a.find { |i| used_unit_numbers.exclude?(i) }