Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
update README.
  • Loading branch information
apotonick committed Nov 10, 2015
1 parent 34e5b1b commit 7ab6276
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions README.markdown
Expand Up @@ -375,7 +375,7 @@ This allows an easy way to discover hypermedia and build navigational logic on t

## Media Formats

While Roar comes with a built-in hypermedia format, there's official media types that are widely recognized. Roar currently supports HAL and Collection+JSON. Support for Siren and JSON-API is planned when there's sponsors.
While Roar comes with a built-in hypermedia format, there's official media types that are widely recognized. Roar currently supports HAL and JSON API.

Simply by including a module you make your representer understand the media type. This makes it easy to change formats during evaluation.

Expand Down Expand Up @@ -447,8 +447,6 @@ All HAL features in Roar are discussed in the [API docs](http://rdoc.info/github

Roar also supports [JSON-API](http://jsonapi.org/) - yay! It can render _and_ parse singular and collection documents.

Note that you need representable >= 2.1.4 in your `Gemfile`.

### Resource

A minimal representation can be defined as follows.
Expand Down Expand Up @@ -568,53 +566,6 @@ SongsRepresenter.for_collection.prepare([Song.new, Song.new]).from_json("..")
Parsing currently works great with singular documents - for collections, we are still working out how to encode the application semantics. Feel free to help.


## Collection+JSON

The [Collection+JSON media format](http://amundsen.com/media-types/collection/) defines document format and semantics for requests. It is currently experimental as we're still exploring how we optimize the support with Roar. Let us know if you're using it.

```ruby
module SongRepresenter
include Roar::JSON::CollectionJSON
version "1.0"
href { "http://localhost/songs/" }

property :title

items(:class => Song) do
href { "//songs/#{title}" }

property :title, :prompt => "Song title"

link(:download) { "//songs/#{title}.mp3" }
end

template do
property :title, :prompt => "Song title"
end

queries do
link :search do
{:href => "//search", :data => [{:name => "q", :value => ""}]}
end
end
end
```

It renders a document following the Collection+JSON specs.

```
#=> {"collection":{
"template":{"data":[{"name":"title","value":null}]},
"queries":[{"rel":"search","href":"//search","data":[{"name":"q","value":""}]}],
"version":"1.0",
"href":"http://localhost/songs/",
"title":"Roxanne",
"items":null}}
```

We have big plans with this media format, as the object model in Roar plays nicely with Collection+JSON's API semantics.


## Client-Side Support

Being a bi-directional mapper that does rendering _and_ parsing, Roar representers are perfectly suitable for use in clients, too. In many projects, representers are shared as gems between server and client.
Expand Down

0 comments on commit 7ab6276

Please sign in to comment.