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

16 lines
470 B
Ruby

module Mobile
module Entities
class Syllabus < Grape::Entity
expose :title
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 :courses, using: Mobile::Entities::Course
end
end
end