Class: Abroad::Serializers::Json::DottedKeySerializer
- Inherits:
-
JsonSerializer
- Object
- Serializer
- JsonSerializer
- Abroad::Serializers::Json::DottedKeySerializer
- Defined in:
- lib/abroad/serializers/json/dotted_key_serializer.rb
Constant Summary
Constants inherited from Serializer
Instance Attribute Summary collapse
-
#trie ⇒ Object
readonly
Returns the value of attribute trie.
Attributes inherited from JsonSerializer
Attributes inherited from Serializer
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(stream, locale, options = {}) ⇒ DottedKeySerializer
constructor
A new instance of DottedKeySerializer.
- #write_key_value(key, value) ⇒ Object
Methods inherited from JsonSerializer
Methods inherited from Serializer
#close, #encoding, from_stream, open, #write_raw
Constructor Details
#initialize(stream, locale, options = {}) ⇒ DottedKeySerializer
Returns a new instance of DottedKeySerializer.
8 9 10 11 |
# File 'lib/abroad/serializers/json/dotted_key_serializer.rb', line 8 def initialize(stream, locale, = {}) super @trie = Abroad::Serializers::Trie.new end |
Instance Attribute Details
#trie ⇒ Object (readonly)
Returns the value of attribute trie.
6 7 8 |
# File 'lib/abroad/serializers/json/dotted_key_serializer.rb', line 6 def trie @trie end |
Instance Method Details
#flush ⇒ Object
17 18 19 20 21 |
# File 'lib/abroad/serializers/json/dotted_key_serializer.rb', line 17 def flush write_node(trie.root, nil) writer.flush stream.flush end |
#write_key_value(key, value) ⇒ Object
13 14 15 |
# File 'lib/abroad/serializers/json/dotted_key_serializer.rb', line 13 def write_key_value(key, value) trie.add(key.split('.'), encode(value)) end |