File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# OkJson won't work because it doesn't serialize symbols
4
4
# in the same way yajl and json do.
5
- if MultiJson . engine . to_s == 'MultiJson::Engines::OkJson'
6
- raise "Please install the yajl-ruby or json gem"
5
+ if MultiJson . respond_to? ( :adapter )
6
+ raise "Please install the yajl-ruby or json gem" if MultiJson . adapter . to_s == 'MultiJson::Adapters::OkJson'
7
+ elsif MultiJson . respond_to? ( :engine )
8
+ raise "Please install the yajl-ruby or json gem" if MultiJson . engine . to_s == 'MultiJson::Engines::OkJson'
7
9
end
8
10
9
11
module Resque
@@ -19,15 +21,24 @@ def redis
19
21
# Given a Ruby object, returns a string suitable for storage in a
20
22
# queue.
21
23
def encode ( object )
22
- ::MultiJson . encode ( object )
24
+ if MultiJson . respond_to? ( :dump ) && MultiJson . respond_to? ( :load )
25
+ MultiJson . load object
26
+ else
27
+ MultiJson . encode object
28
+ end
29
+
23
30
end
24
31
25
32
# Given a string, returns a Ruby object.
26
33
def decode ( object )
27
34
return unless object
28
35
29
36
begin
30
- ::MultiJson . decode ( object )
37
+ if MultiJson . respond_to? ( :dump ) && MultiJson . respond_to? ( :load )
38
+ MultiJson . dump object
39
+ else
40
+ MultiJson . decode object
41
+ end
31
42
rescue ::MultiJson ::DecodeError => e
32
43
raise DecodeException , e . message , e . backtrace
33
44
end
You can’t perform that action at this time.
0 commit comments