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

16 lines
470 B
Ruby
Raw Normal View History

2016-07-04 16:19:05 +08:00
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
2016-07-04 16:19:05 +08:00
expose :courses, using: Mobile::Entities::Course
end
end
end