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 22
33# OkJson won't work because it doesn't serialize symbols
44# 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'
79end
810
911module Resque
@@ -19,15 +21,24 @@ def redis
1921 # Given a Ruby object, returns a string suitable for storage in a
2022 # queue.
2123 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+
2330 end
2431
2532 # Given a string, returns a Ruby object.
2633 def decode ( object )
2734 return unless object
2835
2936 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
3142 rescue ::MultiJson ::DecodeError => e
3243 raise DecodeException , e . message , e . backtrace
3344 end
You can’t perform that action at this time.
0 commit comments