hessian2 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hessian2/hessian_writer.rb +8 -8
- data/lib/hessian2/version.rb +1 -1
- metadata +1 -1
@@ -27,7 +27,7 @@ module Hessian2
|
|
27
27
|
end
|
28
28
|
write(TypeWrapper.new('X', obj), refs, chunks)
|
29
29
|
else
|
30
|
-
if obj.
|
30
|
+
if obj.ascii_only?
|
31
31
|
chunks << [ 'X', obj.size ].pack('an') << obj
|
32
32
|
else
|
33
33
|
chunks << [ 'X', obj.size, obj.unpack('U*') ].flatten.pack('anU*')
|
@@ -72,7 +72,7 @@ module Hessian2
|
|
72
72
|
end
|
73
73
|
write(val, refs, chunks)
|
74
74
|
else
|
75
|
-
if val.
|
75
|
+
if val.ascii_only?
|
76
76
|
chunks << [ 'S', val.size ].pack('an') << val
|
77
77
|
else
|
78
78
|
chunks << [ 'S', val.size, val.unpack('U*') ].flatten.pack('anU*')
|
@@ -83,8 +83,8 @@ module Hessian2
|
|
83
83
|
str = val.to_s
|
84
84
|
[ 'S', str.size ].pack('an') << str # string
|
85
85
|
when Array
|
86
|
-
|
87
|
-
return [ 'R',
|
86
|
+
idx = refs[val.object_id]
|
87
|
+
return [ 'R', idx ].pack('aN') if idx
|
88
88
|
|
89
89
|
refs[val.object_id] = refs.size
|
90
90
|
|
@@ -94,8 +94,8 @@ module Hessian2
|
|
94
94
|
val.each{ |v| str << write(v, refs) }
|
95
95
|
str << 'z' # list
|
96
96
|
when Hash
|
97
|
-
|
98
|
-
return [ 'R',
|
97
|
+
idx = refs[val.object_id]
|
98
|
+
return [ 'R', idx ].pack('aN') if idx
|
99
99
|
|
100
100
|
refs[val.object_id] = refs.size
|
101
101
|
|
@@ -107,7 +107,7 @@ module Hessian2
|
|
107
107
|
end
|
108
108
|
str << 'z' # map
|
109
109
|
else # covert val to hash
|
110
|
-
|
110
|
+
h = {}.tap do |h|
|
111
111
|
val.instance_variables.each {|var| h[var.to_s.delete("@")] = val.instance_variable_get(var) }
|
112
112
|
end
|
113
113
|
|
@@ -122,7 +122,7 @@ module Hessian2
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
write(
|
125
|
+
write(h, refs, chunks, type)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
data/lib/hessian2/version.rb
CHANGED