diff --git a/CHANGES.markdown b/CHANGES.markdown index 9802ab5..d7c08ed 100644 --- a/CHANGES.markdown +++ b/CHANGES.markdown @@ -1,3 +1,7 @@ +h2. 0.1.4 + +* Added a generator to create modules from the command-line. Thanks to Guilherme Cavalcanti for working on this. + h2. 0.1.3 * Fix a bug where `TestCase` wouldn't work in 3.2. diff --git a/README.markdown b/README.markdown index 6bf8749..506f793 100644 --- a/README.markdown +++ b/README.markdown @@ -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. @@ -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.