lib/toxiproxy.rb in toxiproxy-0.1.0 vs lib/toxiproxy.rb in toxiproxy-0.1.1

- old
+ new

@@ -83,16 +83,15 @@ def self.[](query) return grep(query) if query.is_a?(Regexp) find_by_name!(query) end - def self.populate(path) - proxies = JSON.parse(File.read(path), symbolize_names: true) - proxies = proxies.map { |proxy| self.new(proxy) } + def self.populate(*proxies) + proxies = proxies.first if proxies.first.is_a?(Array) - proxies.each do |proxy| - proxy.create unless find_by_name(proxy.name) - end + proxies.map { |proxy| + self.create(proxy) unless find_by_name(proxy[:name]) + }.compact end # Set an upstream toxic. def upstream(toxic = nil, attrs = {}) return @upstream unless toxic