1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[mock] fix Fog::Mock.reset

This commit is contained in:
Dan Peterson 2011-05-19 22:35:37 -03:00
parent 4b3e9dc462
commit 63b9ea6eb0

View file

@ -64,13 +64,15 @@ module Fog
end
def self.reset
providers = Fog.providers.map{|p| eval("Fog::#{p}")}
services = providers.map{|p| p.constants.map{|s| eval("#{p}::#{s}")}}.flatten
services = services.select {|s| s.constants.include?(:Mock)}
providers = Fog.providers.map {|p| Fog.const_get(p) }
possible_service_constants = providers.map {|p| p.constants.map {|c| p.const_get(c) } }.flatten
# c.to_sym is 1.8.7 / 1.9.2 compat
services = possible_service_constants.select {|s| s.constants.map {|c| c.to_sym }.include?(:Mock) }
service_mocks = services.map {|s| s.const_get(:Mock) }
services.each do |service|
next unless service::Mock.respond_to?(:reset)
service::Mock.reset
service_mocks.each do |service_mock|
next unless service_mock.respond_to?(:reset)
service_mock.reset
end
end