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

26 lines
656 B
Ruby
Raw Normal View History

2015-01-22 09:30:29 +08:00
module Mobile
module Entities
class Attachment < Grape::Entity
def self.attachment_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
f[field]
elsif f.is_a?(::Attachment)
if f.respond_to?(field)
f.send(field)
else
#case field
# when ""
#end
end
end
end
end
2015-04-29 17:46:39 +08:00
attachment_expose :id
2015-01-22 09:30:29 +08:00
attachment_expose :filename
attachment_expose :description
2015-04-29 17:46:39 +08:00
attachment_expose :downloads
attachment_expose :quotes
2015-01-22 09:30:29 +08:00
end
end
end