Skip to content

Commit 0529e92

Browse files
author
Michael Bleigh
committed
Removes Entities from README and adds link to Frontier. Defaults versioning to path.
1 parent e536bde commit 0529e92

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

README.markdown

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Grape
2-
[![Build Status](http://travis-ci.org/intridea/grape.png)](http://travis-ci.org/intridea/grape)
1+
# Grape [![Build Status](http://travis-ci.org/intridea/grape.png)](http://travis-ci.org/intridea/grape)
2+
3+
**Note:** This is the `master` branch of Grape where we're trying to maintain things to be relatively stable. If you want to live on the edge, check out the [frontier](https://github.com/intridea/grape/tree/frontier).
34

45
Grape is a REST-like API micro-framework for Ruby. It is built to complement existing web application frameworks such as Rails and Sinatra by providing a simple DSL to easily provide APIs. It has built-in support for common conventions such as multiple formats, subdomain/prefix restriction, and versioning.
56

@@ -116,39 +117,6 @@ class API < Grape::API
116117
end
117118
````
118119

119-
120-
## Working with Entities
121-
122-
A common problem in designing Ruby APIs is that you probably don't want
123-
the exact structure of your data models exposed. ActiveRecord, for
124-
instance, will dump all of its attributes. While you can override
125-
`#as_json` to alter this behavior somewhat, what is really needed is an
126-
intermediary layer between the model and the API. This is where the
127-
`Grape::Entity` class comes in.
128-
129-
```ruby
130-
module Entities
131-
class User < Grape::Entity
132-
expose :first_name, :last_name
133-
expose :email, :if => {:authenticated => true}
134-
expose :name, :id => {:version => 'v1'} # deprecated
135-
end
136-
end
137-
138-
class API < Grape::API
139-
version 'v1', 'v2'
140-
141-
get '/users/:id' do
142-
present User.find(params[:id]),
143-
:with => Entities::User,
144-
:authenticated => env.key?('api.token')
145-
end
146-
end
147-
```
148-
149-
For more information about Entities, view the project's YARD
150-
documentation.
151-
152120
## Raising Errors
153121

154122
You can raise errors explicitly.

lib/grape/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def version(*args, &block)
7777
if args.any?
7878
options = args.pop if args.last.is_a? Hash
7979
options ||= {}
80-
options = {:using => :header}.merge!(options)
80+
options = {:using => :path}.merge!(options)
8181
@versions = versions | args
8282
nest(block) do
8383
set(:version, args)

0 commit comments

Comments
 (0)