BigW Consortium Gitlab

status_entity.rb 595 Bytes
Newer Older
1 2 3
class StatusEntity < Grape::Entity
  include RequestAwareEntity

4
  expose :icon, :text, :label, :group
5 6 7

  expose :has_details?, as: :has_details
  expose :details_path
8

Luke "Jared" Bennett committed
9
  expose :favicon do |status|
10 11 12 13
    dir = 'ci_favicons'
    dir = File.join(dir, 'dev') if Rails.env.development?

    ActionController::Base.helpers.image_path(File.join(dir, "#{status.favicon}.ico"))
Luke "Jared" Bennett committed
14
  end
15 16 17 18 19 20 21

  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
22
end