Sha256: 98b08c48483064219b3ad9106fef869e1da3320ff9f4d1bdb143379a64eb3edb
Contents?: true
Size: 958 Bytes
Versions: 2
Compression:
Stored size: 958 Bytes
Contents
module Acme module Entities class Tool < Grape::Entity root 'tools', 'tool' expose :id expose :length, documentation: { type: :string, desc: 'length of the tool' } expose :weight, documentation: { type: :string, desc: 'weight of the tool' } expose :foo, documentation: { type: :string, desc: 'foo' }, if: ->(_tool, options) { options[:foo] } do |_tool, options| options[:foo] end end class API < Grape::API format :json content_type :xml, 'application/xml' formatter :xml, proc { |object| object[object.keys.first].to_xml root: object.keys.first } desc 'Exposes an entity' namespace :entities do desc 'Expose a tool', params: Acme::Entities::Tool.documentation get ':id' do present OpenStruct.new(id: params[:id], length: 10, weight: '20kg'), with: Acme::Entities::Tool, foo: params[:foo] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vitals-0.4.0 | integration/multiverse/grape-on-rack/api/entities.rb |
vitals-0.3.0 | integration/multiverse/grape-on-rack/api/entities.rb |