parent
b949f70c64
commit
b13f2b2dc8
@ -0,0 +1,28 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class HomeworkAttach < Grape::Entity
|
||||
def self.homework_attach_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
elsif f.is_a?(::HomeworkAttach)
|
||||
if f.respond_to?(field)
|
||||
f.send(field)
|
||||
else
|
||||
case field
|
||||
when :homework_times
|
||||
f.bid.courses.first.homeworks.index(f.bid) + 1 unless (f.bid.nil? || f.bid.courses.nil? || f.bid.courses.first.nil?)
|
||||
#course.homeworks.index(@bid) + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homework_attach_expose :id
|
||||
homework_attach_expose :name
|
||||
homework_attach_expose :homework_times
|
||||
#homework_attach_expose :user
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue