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
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/serializers/pipeline_serializer.rb', line 8 def represent(resource, opts = {}) if resource.is_a?(ActiveRecord::Relation) resource = resource.preload(preloaded_relations) end if paginated? resource = paginator.paginate(resource) end if opts.delete(:preload) resource = Gitlab::Ci::Pipeline::Preloader.preload!(resource) end super(resource, opts) end |
#represent_stages(resource) ⇒ Object
32 33 34 35 36 37 |
# File 'app/serializers/pipeline_serializer.rb', line 32 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
25 26 27 28 29 30 |
# File 'app/serializers/pipeline_serializer.rb', line 25 def represent_status(resource) return {} unless resource.present? data = represent(resource, { only: [{ details: [:status] }] }) data.dig(:details, :status) || {} end |