Sha256: 91ec49308cf79422d8dda50452c1e2296f387e05249154c5b86bc15013c96a9d

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

# DecorateResource

It decorates your idiomatic Rails controller resources by running them through a decorator.

## Installation

Add this line to your application's Gemfile:

    gem 'decorate_resource'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install decorate_resource

## Usage

Your controllers will gain a decorate_resource macro that will take your instanciated variables and run them through an appropriately named decorator. Here's a before and after:

**Before:**

```ruby
class UsersController < ApplicationController
  load_resource

  def index
    @users # [User, User, ...]
  end

  def show
    @user # User
  end
end
```

**After**

```ruby
class UsersController < ApplicationController
  load_resource
  decorate_resource

  def index
    @users # [UserDecorator, UserDecorator, ...]
  end

  def show
    @user # UserDecorator
  end
end
```

## License

MIT

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decorate_resource-1.0.0 README.md