lib/toxiproxy/toxic_collection.rb in toxiproxy-0.0.2 vs lib/toxiproxy/toxic_collection.rb in toxiproxy-0.1.0

- old
+ new

@@ -1,16 +1,16 @@ class Toxiproxy class ToxicCollection extend Forwardable attr_accessor :toxics - attr_reader :proxy + attr_reader :proxies def_delegators :@toxics, :<<, :find - def initialize(proxy) - @proxy = proxy + def initialize(proxies) + @proxies = proxies @toxics = [] end def apply(&block) @toxics.each(&:enable) @@ -18,25 +18,29 @@ ensure @toxics.each(&:disable) end def upstream(toxic_name, attrs = {}) - toxics << Toxic.new( - name: toxic_name, - proxy: proxy, - direction: :upstream, - attrs: attrs - ) + proxies.each do |proxy| + toxics << Toxic.new( + name: toxic_name, + proxy: proxy, + direction: :upstream, + attrs: attrs + ) + end self end def downstream(toxic_name, attrs = {}) - toxics << Toxic.new( - name: toxic_name, - proxy: proxy, - direction: :downstream, - attrs: attrs - ) + proxies.each do |proxy| + toxics << Toxic.new( + name: toxic_name, + proxy: proxy, + direction: :downstream, + attrs: attrs + ) + end self end end end