Class: PipelineSerializer
- Inherits:
-
BaseSerializer
- Object
- BaseSerializer
- PipelineSerializer
- Includes:
- WithPagination
- Defined in:
- app/serializers/pipeline_serializer.rb
Instance Attribute Summary
Attributes included from WithPagination
Attributes inherited from BaseSerializer
Instance Method Summary collapse
-
#represent(resource, opts = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
- #represent_stages(resource) ⇒ Object
-
#represent_status(resource) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
Methods included from WithPagination
Methods inherited from BaseSerializer
Constructor Details
This class inherits a constructor from BaseSerializer
Instance Method Details
#represent(resource, opts = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
9 10 11 12 13 14 15 |
# File 'app/serializers/pipeline_serializer.rb', line 9 def represent(resource, opts = {}) resource = resource.preload(preloaded_relations(**opts)) if resource.is_a?(ActiveRecord::Relation) resource = paginator.paginate(resource) if paginated? resource = Gitlab::Ci::Pipeline::Preloader.preload!(resource) if opts.delete(:preload) super(resource, opts) end |
#represent_stages(resource) ⇒ Object
25 26 27 28 29 30 |
# File 'app/serializers/pipeline_serializer.rb', line 25 def represent_stages(resource) return {} unless resource.present? data = represent(resource, { only: [{ details: [:stages] }], preload: true }) data.dig(:details, :stages) || [] end |
#represent_status(resource) ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
18 19 20 21 22 23 |
# File 'app/serializers/pipeline_serializer.rb', line 18 def represent_status(resource) return {} unless resource.present? data = represent(resource, { only: [{ details: [:status] }] }) data.dig(:details, :status) || {} end |