Class: OrientDbClient::Deserializers::Deserializer7

Inherits:
Object
  • Object
show all
Defined in:
lib/orient_db_client/deserializers/deserializer7.rb

Constant Summary collapse

@@string_matcher =
/^"[^"]*"$/

Instance Method Summary collapse

Instance Method Details

#deserialize(text) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/orient_db_client/deserializers/deserializer7.rb', line 10

def deserialize(text)
    result = { :document => {}, :structure => {} }
    struct_info = {}

    serialized_record = text

    if m = serialized_record.match(/([^,@]+)@/)
        result[:class] = m[1]
        serialized_record.gsub!(/^[^@]*@/, '')
    end

    tokens = serialized_record.split(",")
    
    while token = tokens.shift
        field, value = parse_field(token, tokens, struct_info)

        result[:document][field] = value
        result[:structure][field] = struct_info[:type]
    end

    result
end