Skip to content

Commit

Permalink
adding CHANGES and README for generators.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Aug 19, 2013
1 parent 83b098e commit 3ab7373
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.markdown
@@ -1,3 +1,7 @@
h2. 0.1.4

* Added a generator to create modules from the command-line. Thanks to Guilherme Cavalcanti <guiocavalcanti> for working on this.

h2. 0.1.3

* Fix a bug where `TestCase` wouldn't work in 3.2.
Expand Down
32 changes: 32 additions & 0 deletions README.markdown
Expand Up @@ -11,13 +11,44 @@ Roar is a framework for parsing and rendering REST documents. For a better overv
* URL helpers in representers
* Better tests
* Autoloading
* Generators

This gem works with all Rails >= 3.x.


## Generators

The generator will create the representer modules in `app/representers` for you.

Here's an example.

```shell
rails g representer Band id name
```

This will create the file `app/representers/band_representer.rb` with the following content,

```ruby
module BandRepresenter
include Roar::Representer::JSON

property :id
property :name
end
```

You can change the format (e.g. XML), and pass arbitrary options to customize the generated representer. For all available options, just run

```shell
rails g representer
```


## Rendering with #respond_with

roar-rails provides a number of baked-in rendering methods.


### Conventional Rendering

Easily render resources using representers with the built-in responder.
Expand Down Expand Up @@ -129,6 +160,7 @@ end

In decorators' link blocks you currently have to use `represented` to get the actual represented model (this is `self` in module representers).


## Passing Options

Both rendering and consuming support passing user options to the representer.
Expand Down

0 comments on commit 3ab7373

Please sign in to comment.