2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
class IssueSerializer < BaseSerializer
|
2018-03-17 18:26:18 +05:30
|
|
|
# This overrided method takes care of which entity should be used
|
2019-02-13 22:33:31 +05:30
|
|
|
# to serialize the `issue` based on `serializer` key in `opts` param.
|
2018-03-17 18:26:18 +05:30
|
|
|
# Hence, `entity` doesn't need to be declared on the class scope.
|
2019-02-13 22:33:31 +05:30
|
|
|
def represent(issue, opts = {})
|
2018-03-17 18:26:18 +05:30
|
|
|
entity =
|
|
|
|
case opts[:serializer]
|
|
|
|
when 'sidebar'
|
2019-02-13 22:33:31 +05:30
|
|
|
IssueSidebarBasicEntity
|
|
|
|
when 'sidebar_extras'
|
|
|
|
IssueSidebarExtrasEntity
|
|
|
|
when 'board'
|
|
|
|
IssueBoardEntity
|
2018-03-17 18:26:18 +05:30
|
|
|
else
|
|
|
|
IssueEntity
|
|
|
|
end
|
|
|
|
|
2019-02-13 22:33:31 +05:30
|
|
|
super(issue, opts, entity)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|