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:
class UsersController < ApplicationController
load_resource
def index
@users
end
def show
@user
end
end
After
class UsersController < ApplicationController
load_resource
decorate_resource
def index
@users
end
def show
@user
end
end
License
MIT