lib/fog/ecloud/mock_data_classes.rb in fog-1.22.0 vs lib/fog/ecloud/mock_data_classes.rb in fog-1.22.1

- old
+ new

@@ -94,11 +94,10 @@ def virtual_machine_from_href(href) find_href_prefixed_in(href, all_virtual_machines) end - def all_networks all_vdcs.map(&:networks).flatten end def network_from_href(href) @@ -194,15 +193,15 @@ end private def find_href_in(href, objects) - objects.detect {|o| o.href == href } + objects.find {|o| o.href == href } end def find_href_prefixed_in(href, objects) - objects.detect {|o| href =~ %r{^#{o.href}($|/)} } + objects.find {|o| href =~ %r{^#{o.href}($|/)} } end end class MockVersion < Base def version @@ -224,11 +223,10 @@ end def environments @vdcs ||= [] end - end class MockVdc < Base def name self[:name] @@ -393,11 +391,11 @@ end end class MockNetworkIps < Base def items - @items ||= _parent.usable_subnet_ips.inject({}) do |out, subnet_ip| + @items ||= _parent.usable_subnet_ips.reduce({}) do |out, subnet_ip| out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self)) end end def ordered_ips @@ -417,11 +415,11 @@ def ip self[:ip] end def used_by - self[:used_by] || _parent._parent._parent.virtual_machines.detect {|v| v.ip == ip } + self[:used_by] || _parent._parent._parent.virtual_machines.find {|v| v.ip == ip } end def status if used_by "Assigned" @@ -505,15 +503,15 @@ def power_on! self[:status] = 4 end def size - disks.inject(0) {|s, d| s + d.vcloud_size } + disks.reduce(0) {|s, d| s + d.vcloud_size } end def network_ip - if network = _parent.networks.detect {|n| n.ip_collection.items[ip] } + if network = _parent.networks.find {|n| n.ip_collection.items[ip] } network.ip_collection.items[ip] end end # from fog ecloud server's _compose_vapp_data @@ -562,11 +560,11 @@ sort! {|a, b| a.address <=> b.address } self end def at_address(address) - detect {|d| d.address == address } + find {|d| d.address == address } end end class MockVirtualMachineDisk < Base def size @@ -597,10 +595,10 @@ def items public_ip_internet_services + backup_internet_services end def public_ip_internet_services - _parent.public_ip_collection.items.inject([]) do |services, public_ip| + _parent.public_ip_collection.items.reduce([]) do |services, public_ip| services + public_ip.internet_service_collection.items end end def backup_internet_services