socialforge/app/api/mobile/entities/project.rb

19 lines
552 B
Ruby
Raw Normal View History

2016-07-25 15:20:01 +08:00
module Mobile
module Entities
class Project < Grape::Entity
expose :name
expose :id
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
can_setting = instance.user_id == current_user.id ? true : false
can_setting = false if instance.id.nil?
can_setting
end
expose :member_count, if: lambda { |instance, options| options[:user] } do |instance, options|
instance.members.count
end
end
end
end