summaryrefslogtreecommitdiffstats
path: root/app/views/news/show.api.rsb
blob: 0dd3a3b78640f7a7e40ecfd49ab6e5c4aef3b6d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
api.news do
  api.id @news.id
  api.project(:id => @news.project_id, :name => @news.project.name) unless @news.project.nil?
  api.author(:id => @news.author_id, :name => @news.author.name) unless @news.author.nil?
  api.title @news.title
  api.summary @news.summary unless @news.summary.blank?
  api.description @news.description
  api.created_on @news.created_on

  api.array :attachments do
    @news.attachments.each do |attachment|
      render_api_attachment(attachment, api)
    end
  end if include_in_api_response?('attachments')

  api.array :comments do
    @comments.each do |comment|
      api.comment :id => comment.id do
        api.author(:id => comment.author_id, :name => comment.author.name) unless comment.author.nil?
        api.content comment.content
      end
    end
  end if include_in_api_response?('comments')
end