gitlab-org--gitlab-foss/app/serializers/status_entity.rb

23 lines
595 B
Ruby
Raw Normal View History

class StatusEntity < Grape::Entity
include RequestAwareEntity
2017-04-13 06:09:20 -04:00
expose :icon, :text, :label, :group
expose :has_details?, as: :has_details
expose :details_path
2017-04-13 06:09:20 -04:00
2017-04-13 07:14:31 -04:00
expose :favicon do |status|
2017-04-25 12:15:41 -04:00
dir = 'ci_favicons'
dir = File.join(dir, 'dev') if Rails.env.development?
ActionController::Base.helpers.image_path(File.join(dir, "#{status.favicon}.ico"))
2017-04-13 07:14:31 -04:00
end
2017-05-06 12:45:46 -04:00
expose :action, if: -> (status, _) { status.has_action? } do
expose :action_icon, as: :icon
expose :action_title, as: :title
expose :action_path, as: :path
expose :action_method, as: :method
end
end