summaryrefslogtreecommitdiffstats
path: root/app/views/members/index.api.rsb
blob: dd591ea7c1b2a4221e41d80352663f39efaead5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
api.array :memberships, api_meta(:total_count => @member_count, :offset => @offset, :limit => @limit) do
  @members.each do |membership|
    api.membership do
      api.id membership.id
      api.project :id => membership.project.id, :name => membership.project.name
      api.__send__ membership.principal.class.name.underscore, :id => membership.principal.id, :name => membership.principal.name
      api.array :roles do
        membership.member_roles.each do |member_role|
          if member_role.role
            attrs = {:id => member_role.role.id, :name => member_role.role.name}
            attrs.merge!(:inherited => true) if member_role.inherited_from.present?
            api.role attrs
          end 
        end
      end
    end
  end
end