Class: Abroad::Serializers::Yaml::RailsSerializer

Inherits:
YamlSerializer show all
Defined in:
lib/abroad/serializers/yaml/rails_serializer.rb

Constant Summary

Constants inherited from Serializer

Serializer::DEFAULT_ENCODING

Instance Attribute Summary collapse

Attributes inherited from YamlSerializer

#writer

Attributes inherited from Serializer

#locale, #options, #stream

Instance Method Summary collapse

Methods inherited from Serializer

#close, #encoding, from_stream, open

Constructor Details

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

Returns a new instance of RailsSerializer.


8
9
10
11
# File 'lib/abroad/serializers/yaml/rails_serializer.rb', line 8

def initialize(stream, locale, options = {})
  super
  @trie = Abroad::Serializers::Trie.new
end

Instance Attribute Details

#trieObject (readonly)

Returns the value of attribute trie


6
7
8
# File 'lib/abroad/serializers/yaml/rails_serializer.rb', line 6

def trie
  @trie
end

Instance Method Details

#flushObject


22
23
24
25
26
27
# File 'lib/abroad/serializers/yaml/rails_serializer.rb', line 22

def flush
  writer.write_map(locale)
  write_node(trie.root, locale)
  writer.flush
  stream.flush
end

#write_key_value(key, value) ⇒ Object


17
18
19
20
# File 'lib/abroad/serializers/yaml/rails_serializer.rb', line 17

def write_key_value(key, value)
  key_parts = split_key(key)
  add_key_value(key_parts, value)
end

#write_raw(text) ⇒ Object


13
14
15
# File 'lib/abroad/serializers/yaml/rails_serializer.rb', line 13

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