gitlab-org--gitlab-foss/app/serializers/issue_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
595 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class IssueSerializer < BaseSerializer
2017-10-31 12:15:03 -04:00
# This overrided method takes care of which entity should be used
# to serialize the `issue` based on `serializer` key in `opts` param.
2017-10-31 12:15:03 -04:00
# Hence, `entity` doesn't need to be declared on the class scope.
2018-12-03 10:23:38 -05:00
def represent(issue, opts = {})
2017-10-31 12:15:03 -04:00
entity =
case opts[:serializer]
2018-11-29 23:03:35 -05:00
when 'sidebar'
IssueSidebarBasicEntity
when 'sidebar_extras'
IssueSidebarExtrasEntity
2018-12-03 10:23:38 -05:00
when 'board'
IssueBoardEntity
2017-10-31 12:15:03 -04:00
else
IssueEntity
end
2018-12-03 10:23:38 -05:00
super(issue, opts, entity)
2017-10-31 12:15:03 -04:00
end
end