BigW Consortium Gitlab

merge_request_serializer.rb 528 Bytes
Newer Older
1
class MergeRequestSerializer < BaseSerializer
2
  # This overrided method takes care of which entity should be used
3
  # to serialize the `merge_request` based on `serializer` key in `opts` param.
4 5
  # Hence, `entity` doesn't need to be declared on the class scope.
  def represent(merge_request, opts = {})
6 7 8 9
    entity =
      case opts[:serializer]
      when 'basic', 'sidebar'
        MergeRequestBasicEntity
10
      else # It's 'widget'
11
        MergeRequestWidgetEntity
12 13
      end

14 15
    super(merge_request, opts, entity)
  end
16
end