Skip to content

Commit

Permalink
Merge pull request #2463 from Shopify/0-9-stable-shapes
Browse files Browse the repository at this point in the history
Improve shape friendliness of ActionController::Serialization
  • Loading branch information
byroot authored Apr 9, 2024
2 parents 07da9d0 + 59e0333 commit 91f57c1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/action_controller/serialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def serialization_scope(scope)
end
end

def initialize(*)
super
@namespace_for_serializer = nil
end
ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)

[:_render_option_json, :_render_with_renderer_json].each do |renderer_method|
define_method renderer_method do |resource, options|
serializer = build_json_serializer(resource, options)
Expand All @@ -60,7 +66,8 @@ def serialization_scope(scope)
private

def namespace_for_serializer
@namespace_for_serializer ||= namespace_for_class(self.class) unless namespace_for_class(self.class) == Object
@namespace_for_serializer ||= namespace_for_class(self.class)
@namespace_for_serializer unless @namespace_for_serializer == Object
end

def namespace_for_class(klass)
Expand Down

0 comments on commit 91f57c1

Please sign in to comment.