Skip to content

Commit 0efee09

Browse files
committed
Improve renderer compatibility
Renderers' return value has been changed since Rails 3.1. rails/rails@4f04452
1 parent 8a56215 commit 0efee09

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/msgpack_rails.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ class Rails < ::Rails::Engine
3535

3636
::Mime::Type.register "application/msgpack", :msgpack
3737

38-
::ActionController::Renderers.add :msgpack do |data, options|
39-
self.content_type = Mime[:msgpack]
40-
self.response_body = data.is_a?(String) ? data : data.to_msgpack(options)
38+
if ::Rails::VERSION::MAJOR > 3 || ::Rails::VERSION::MINOR > 0
39+
::ActionController::Renderers.add :msgpack do |data, options|
40+
self.content_type = Mime[:msgpack]
41+
data.is_a?(String) ? data : data.to_msgpack(options)
42+
end
43+
else
44+
::ActionController::Renderers.add :msgpack do |data, options|
45+
self.content_type = Mime[:msgpack]
46+
self.response_body = data.is_a?(String) ? data : data.to_msgpack(options)
47+
end
4148
end
4249
end
4350
end

0 commit comments

Comments
 (0)