lib/scout/persist/serialize.rb in scout-essentials-1.3.1 vs lib/scout/persist/serialize.rb in scout-essentials-1.6.0
- old
+ new
@@ -32,10 +32,12 @@
content.to_yaml
when :json
content.to_json
when :marshal
Marshal.dump(content)
+ when :annotation, :annotations
+ Annotation.tsv(content, :all).to_s
else
if m = type.to_s.match(/(.*)_array/)
type = m[1].to_sym
content.collect{|c| serialize(c, type) } * "\n"
else
@@ -67,10 +69,12 @@
YAML.parse(serialized)
when :json
JSON.parse(serialized)
when :marshal
Marshal.load(serialized)
+ when :annotation, :annotations
+ Annotation.load_tsv(TSV.open(serialized))
else
if m = type.to_s.match(/(.*)_array/)
type = m[1].to_sym
new_content = serialized.split("\n")
new_content.collect{|c| deserialize(c, type) }
@@ -108,10 +112,10 @@
content.force_encoding("ASCII-8BIT") if content.respond_to? :force_encoding
Open.open(file, :mode => 'wb') do |f|
f.puts content
end
content
- else
+ else
serialized = serialize(content, type)
Open.sensible_write(file, serialized, :force => true)
return nil
end
end