Class: Abroad::Serializers::Json::KeyValueSerializer
Constant Summary
collapse
- DEFAULT_INDENT_SPACES =
4
Constants inherited
from Serializer
Serializer::DEFAULT_ENCODING
Instance Attribute Summary
#writer
Attributes inherited from Serializer
#locale, #options, #stream
Instance Method Summary
collapse
#flush, #write_raw
Methods inherited from Serializer
#encoding, #flush, from_stream, open, #write_raw
Constructor Details
#initialize(stream, locale, options = {}) ⇒ KeyValueSerializer
8
9
10
11
|
# File 'lib/abroad/serializers/json/key_value_serializer.rb', line 8
def initialize(stream, locale, options = {})
super
writer.write_object
end
|
Instance Method Details
#close ⇒ Object
21
22
23
24
25
|
# File 'lib/abroad/serializers/json/key_value_serializer.rb', line 21
def close
write_raw("\n") if pretty?
writer.close_object
super
end
|
#write_key_value(key, value) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/abroad/serializers/json/key_value_serializer.rb', line 13
def write_key_value(key, value)
before = pretty? ? "\n#{' ' * indent_spaces}" : ''
writer.write_key_value(
key.encode(encoding), value.encode(encoding), before
)
end
|