lib/json-write-stream/stateful.rb in json-write-stream-1.1.0 vs lib/json-write-stream/stateful.rb in json-write-stream-1.2.0
- old
+ new
@@ -137,16 +137,18 @@
increment
write_key(key)
stream.write(':')
end
- def write_key_value(key, value, before = '')
+ def write_key_value(key, value, options = DEFAULT_OPTIONS)
write_comma
- stream.write(before)
+ stream.write(options.fetch(:before, DEFAULT_OPTIONS[:before]))
increment
write_key(key)
- stream.write(":#{escape(value)}")
+ stream.write(':')
+ stream.write(options.fetch(:between, DEFAULT_OPTIONS[:between]))
+ stream.write(escape(value))
end
def close
stream.write('}')
end
@@ -174,12 +176,12 @@
class StatefulArrayWriter < StatefulWriter
def after_initialize
stream.write('[')
end
- def write_element(element, before = '')
+ def write_element(element, options = DEFAULT_OPTIONS)
write_comma
- stream.write(before)
+ stream.write(options.fetch(:before, DEFAULT_OPTIONS[:before]))
increment
stream.write(escape(element))
end
# prep work