diff options
author | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-03-11 00:16:48 +0900 |
---|---|---|
committer | Shinya Maeda <gitlab.shinyamaeda@gmail.com> | 2017-03-23 17:11:49 +0900 |
commit | a5b96417f39a5ab8b4d2ddde1fd654937244a73c (patch) | |
tree | d50ded7a51a9ae49c3e71b47cd9f41aa0e2d364a /app/serializers | |
parent | 3b635002976e1dd45e58271efdb71f7349719d02 (diff) | |
download | gitlab-ce-a5b96417f39a5ab8b4d2ddde1fd654937244a73c.tar.gz |
with_status to represent_status
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/build_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/build_serializer.rb | 13 | ||||
-rw-r--r-- | app/serializers/pipeline_serializer.rb | 13 |
3 files changed, 11 insertions, 20 deletions
diff --git a/app/serializers/build_entity.rb b/app/serializers/build_entity.rb index 35566c55950..fadd6c5c597 100644 --- a/app/serializers/build_entity.rb +++ b/app/serializers/build_entity.rb @@ -18,10 +18,7 @@ class BuildEntity < Grape::Entity expose :created_at expose :updated_at - - expose :details do - expose :detailed_status, as: :status, with: StatusEntity - end + expose :detailed_status, as: :status, with: StatusEntity private diff --git a/app/serializers/build_serializer.rb b/app/serializers/build_serializer.rb index e0096dc7b4a..2c9cf99811e 100644 --- a/app/serializers/build_serializer.rb +++ b/app/serializers/build_serializer.rb @@ -1,15 +1,12 @@ class BuildSerializer < BaseSerializer entity BuildEntity - def only_status - tap { @status_only = { only: [{ details: [:status] }] } } - end - def represent(resource, opts = {}) - if @status_only.present? - opts.merge!(@status_only) - end - super(resource, opts) end + + def represent_status(resource) + data = represent(resource, { only: [:status] }) + data[:status] + end end diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index c667fc840b2..62f31d4c5ad 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -11,23 +11,20 @@ class PipelineSerializer < BaseSerializer @paginator.present? end - def only_status - tap { @status_only = { only: [{ details: [:status] }] } } - end - def represent(resource, opts = {}) if resource.is_a?(ActiveRecord::Relation) resource = resource.includes(project: :namespace) end - if @status_only.present? - opts.merge!(@status_only) - end - if paginated? super(@paginator.paginate(resource), opts) else super(resource, opts) end end + + def represent_status(resource) + data = represent(resource, { only: [{ details: [:status] }] }) + data[:details][:status] + end end |