2018-07-19 18:43:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-19 02:19:04 +00:00
|
|
|
class IssueSerializer < BaseSerializer
|
2017-10-31 16:15:03 +00:00
|
|
|
# This overrided method takes care of which entity should be used
|
|
|
|
# to serialize the `issue` based on `basic` key in `opts` param.
|
|
|
|
# Hence, `entity` doesn't need to be declared on the class scope.
|
2018-11-09 00:19:48 +00:00
|
|
|
def represent(merge_request, opts = {})
|
2017-10-31 16:15:03 +00:00
|
|
|
entity =
|
|
|
|
case opts[:serializer]
|
|
|
|
when 'sidebar'
|
|
|
|
IssueSidebarEntity
|
|
|
|
else
|
|
|
|
IssueEntity
|
|
|
|
end
|
|
|
|
|
2018-11-09 00:19:48 +00:00
|
|
|
super(merge_request, opts, entity)
|
2017-10-31 16:15:03 +00:00
|
|
|
end
|
2016-11-19 02:19:04 +00:00
|
|
|
end
|