Commit b8498d61 authored by Rajendra Kadam's avatar Rajendra Kadam Committed by James Lopez

Add list, board, broadcast message, contributor and compare into own class files

parent 5f964fcf
---
title: Separate board, list and other entities into own class files
merge_request: 24939
author: Rajendra Kadam
type: added
...@@ -163,49 +163,6 @@ module API ...@@ -163,49 +163,6 @@ module API
end end
end end
class List < Grape::Entity
expose :id
expose :label, using: Entities::LabelBasic
expose :position
end
class Board < Grape::Entity
expose :id
expose :project, using: Entities::BasicProjectDetails
expose :lists, using: Entities::List do |board|
board.destroyable_lists
end
end
class Compare < Grape::Entity
expose :commit, using: Entities::Commit do |compare, _|
compare.commits.last
end
expose :commits, using: Entities::Commit do |compare, _|
compare.commits
end
expose :diffs, using: Entities::Diff do |compare, _|
compare.diffs.diffs.to_a
end
expose :compare_timeout do |compare, _|
compare.diffs.diffs.overflow?
end
expose :same, as: :compare_same_ref
end
class Contributor < Grape::Entity
expose :name, :email, :commits, :additions, :deletions
end
class BroadcastMessage < Grape::Entity
expose :message, :starts_at, :ends_at, :color, :font, :target_path, :broadcast_type
end
class Trigger < Grape::Entity class Trigger < Grape::Entity
include ::API::Helpers::Presentable include ::API::Helpers::Presentable
......
# frozen_string_literal: true
module API
module Entities
class Board < Grape::Entity
expose :id
expose :project, using: Entities::BasicProjectDetails
expose :lists, using: Entities::List do |board|
board.destroyable_lists
end
end
end
end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module API module API
module Entities module Entities
class BroadcastMessage < Grape::Entity class BroadcastMessage < Grape::Entity
expose :id, :message, :starts_at, :ends_at, :color, :font expose :id, :message, :starts_at, :ends_at, :color, :font, :target_path, :broadcast_type
expose :active?, as: :active expose :active?, as: :active
end end
end end
......
# frozen_string_literal: true
module API
module Entities
class Compare < Grape::Entity
expose :commit, using: Entities::Commit do |compare, _|
compare.commits.last
end
expose :commits, using: Entities::Commit do |compare, _|
compare.commits
end
expose :diffs, using: Entities::Diff do |compare, _|
compare.diffs.diffs.to_a
end
expose :compare_timeout do |compare, _|
compare.diffs.diffs.overflow?
end
expose :same, as: :compare_same_ref
end
end
end
# frozen_string_literal: true
module API
module Entities
class Contributor < Grape::Entity
expose :name, :email, :commits, :additions, :deletions
end
end
end
# frozen_string_literal: true
module API
module Entities
class List < Grape::Entity
expose :id
expose :label, using: Entities::LabelBasic
expose :position
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment