diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-03 15:35:57 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-03 15:35:57 +0300 |
commit | 52d333b9f4793ca677b938317f4c8e480b835284 (patch) | |
tree | 88992841403e16bba4db54a446595a2bcf4b1a16 | |
parent | 573921cb9d0b139dec324fb1368feb1347b51624 (diff) |
Remove duplication from build serializer entity
-rw-r--r-- | app/serializers/build_entity.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/app/serializers/build_entity.rb b/app/serializers/build_entity.rb index 38169ab9864..b37bff0b500 100644 --- a/app/serializers/build_entity.rb +++ b/app/serializers/build_entity.rb @@ -5,16 +5,20 @@ class BuildEntity < Grape::Entity expose :name expose :build_url do |build| - @urls.namespace_project_build_url( - build.project.namespace, - build.project, - build) + url_to(:namespace_project_build, build) end expose :retry_url do |build| - @urls.retry_namespace_project_build_url( - build.project.namespace, - build.project, - build) + url_to(:retry_namespace_project_build, build) + end + + expose :play_url, if: ->(build, _) { build.manual? } do |build| + url_to(:retry_namespace_project_build, build) + end + + private + + def url_to(route, build) + @urls.send("#{route}_url", build.project.namespace, build.project, build) end end |