2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-18 21:19:04 -05:00
|
|
|
class IssueSerializer < BaseSerializer
|
2017-10-31 12:15:03 -04:00
|
|
|
# This overrided method takes care of which entity should be used
|
2018-11-27 03:47:10 -05:00
|
|
|
# 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
|
2016-11-18 21:19:04 -05:00
|
|
|
end
|