lib/rambo/raml_models/headers.rb in rambo_ruby-0.2.3 vs lib/rambo/raml_models/headers.rb in rambo_ruby-0.3.0

- old
+ new

@@ -5,17 +5,27 @@ def initialize(headers) @headers = headers end + def add(hash) + headers.merge!(hash) + self + end + + def merge!(other) + add(other.headers) + end + def pretty - beginning, ending = "{\n", "}" + beginning = "{\n" + ending = "}" - contents = headers.map {|key, value| - "\t\"#{key}\" => \"#{value}\"\n" + contents = headers.to_a.map {|pair| + "\t\"#{pair.first}\" => \"#{pair.last}\"\n" } - "#{beginning}#{contents.join}#{ending}" + "#{beginning}#{contents.join("")}#{ending}" end end end end