Class: Abroad::Serializers::Json::JsonSerializer

Inherits:
Serializer
  • Object
show all
Defined in:
lib/abroad/serializers/json/json_serializer.rb

Direct Known Subclasses

KeyValueSerializer

Constant Summary

Constants inherited from Serializer

Serializer::DEFAULT_ENCODING

Instance Attribute Summary collapse

Attributes inherited from Serializer

#locale, #options, #stream

Instance Method Summary collapse

Methods inherited from Serializer

#close, #encoding, from_stream, open, #write_key_value

Constructor Details

#initialize(stream, locale, options = {}) ⇒ JsonSerializer

Returns a new instance of JsonSerializer.


10
11
12
13
# File 'lib/abroad/serializers/json/json_serializer.rb', line 10

def initialize(stream, locale, options = {})
  super
  @writer = JsonWriteStream.from_stream(stream, encoding)
end

Instance Attribute Details

#writerObject (readonly)

Returns the value of attribute writer


8
9
10
# File 'lib/abroad/serializers/json/json_serializer.rb', line 8

def writer
  @writer
end

Instance Method Details

#flushObject


19
20
21
22
# File 'lib/abroad/serializers/json/json_serializer.rb', line 19

def flush
  writer.flush
  stream.flush
end

#write_raw(text) ⇒ Object


15
16
17
# File 'lib/abroad/serializers/json/json_serializer.rb', line 15

def write_raw(text)
  writer.stream.write(text)
end