wamp_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+
3
+ module WampClient
4
+ module Serializer
5
+ class Base
6
+
7
+ attr_accessor :type
8
+
9
+ # Serializes the object
10
+ # @param object - The object to serialize
11
+ def serialize(object)
12
+
13
+ end
14
+
15
+ # Deserializes the object
16
+ # @param string [String] - The string to deserialize
17
+ # @return The deserialized object
18
+ def deserialize(string)
19
+
20
+ end
21
+
22
+ end
23
+
24
+ class JSONSerializer < Base
25
+
26
+ def initialize
27
+ self.type = 'json'
28
+ end
29
+
30
+ def serialize(object)
31
+ JSON.generate object
32
+ end
33
+
34
+ def deserialize(string)
35
+ JSON.parse(string, {:symbolize_names => true})
36
+ end
37
+
38
+ end
39
+ end
40
+ end