Minor clarity revisions
This commit is contained in:
parent
1a917487c3
commit
5448aba31a
|
@ -133,11 +133,7 @@ Add the dependency to your `Gemfile`:
|
||||||
gem "draper"
|
gem "draper"
|
||||||
```
|
```
|
||||||
|
|
||||||
Run bundle:
|
Then run `bundle` from the project directory.
|
||||||
|
|
||||||
```
|
|
||||||
bundle
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generate the Decorator
|
### Generate the Decorator
|
||||||
|
|
||||||
|
@ -149,7 +145,7 @@ rails generate draper:decorator Article
|
||||||
|
|
||||||
### Writing Methods
|
### Writing Methods
|
||||||
|
|
||||||
Open the decorator model (ex: `app/decorators/article_decorator.rb`) and add normal instance methods. To access the wrapped source object, use a method named by the source object passed to `decorates`:
|
Open the decorator model (ex: `app/decorators/article_decorator.rb`) and add normal instance methods. To access the wrapped source object, use a method named after the `decorates` argument:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
class ArticleDecorator < ApplicationDecorator
|
class ArticleDecorator < ApplicationDecorator
|
||||||
|
@ -208,7 +204,7 @@ ArticleDecorator.new(Article.find(params[:id]))`
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
ArticleDecorator.decorate(Article.first) # Returns one instance of ArticleDecorator
|
ArticleDecorator.decorate(Article.first) # Returns one instance of ArticleDecorator
|
||||||
ArticleDecorator.decorate(Article.all) # Returns an array of ArticleDecorator instances
|
ArticleDecorator.decorate(Article.all) # Returns an enumeration proxy of ArticleDecorator instances
|
||||||
```
|
```
|
||||||
|
|
||||||
* Call `.find` to do automatically do a lookup on the `decorates` class:
|
* Call `.find` to do automatically do a lookup on the `decorates` class:
|
||||||
|
|
Loading…
Reference in New Issue