Skip to content

Instantly share code, notes, and snippets.

@Ji-Yuhang
Created September 21, 2017 02:23
Show Gist options
  • Save Ji-Yuhang/558f62a7d347b7383d035e1894b9cc3a to your computer and use it in GitHub Desktop.
Save Ji-Yuhang/558f62a7d347b7383d035e1894b9cc3a to your computer and use it in GitHub Desktop.
grape expose format_with: datetime, if: {type: :full}
module Entities::Admin
class OptionType < Grape::Entity
expose :id, documentation: {type: String, desc: 'ID'}
expose :name, documentation: {type: String, desc: '商品属性名称'}
expose :group_name, documentation: {type: String, desc: '属性群名称'}
expose :required, documentation: {type: Boolean, desc: '是否必填'}
expose :position, documentation: {type: Boolean, desc: '排序号'}
expose :phone_category_id, documentation: {type: String, desc: '商品类别ID'}, if: { type: :full }
expose :values, documentation: {type: String, desc: '商品属性值'}, if: { type: :full }
expose :category_names, documentation: {type: String, desc: '商品属性值'}, if: { type: :full }
expose :created_at, documentation: {type: DateTime, desc: '创建时间'}, format_with: :datetime, if: { type: :full }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment