Skip to content

Commit 6fbeb9a

Browse files
committed
Fix deprecation warnings on Rails 6
takes into account suggestions from @bf4
1 parent bb0f9d0 commit 6fbeb9a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/action_controller/serialization.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ def serialization_scope(scope)
2323
end
2424

2525
def namespace_for_serializer
26-
@namespace_for_serializer ||= self.class.parent unless self.class.parent == Object
26+
@namespace_for_serializer ||= namespace_for_class(self.class) unless namespace_for_class(self.class) == Object
27+
end
28+
29+
def namespace_for_class(klass)
30+
if Module.method_defined?(:module_parent)
31+
klass.module_parent
32+
else
33+
klass.parent
34+
end
2735
end
2836

2937
def serialization_scope

test/action_controller/namespace_lookup_test.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ def namespace_set_by_request_headers
125125
tests Api::V3::LookupTestController
126126

127127
setup do
128-
@test_namespace = self.class.parent
128+
@test_namespace =
129+
if Module.method_defined?(:module_parent)
130+
self.class.module_parent
131+
else
132+
self.class.parent
133+
end
129134
end
130135

131136
test 'uses request headers to determine the namespace' do

0 commit comments

Comments
 (0)