Haberdasher

Decorator library providing a draper style API for Rails 2.3.x apps.
Installation
Rails 2.3.x
If you're using bundler, then add this line to your application's Gemfile:
gem 'haberdasher'
And then execute:
$ bundle
If you're not using bundler:
# in config/environment.rb
config.gem "haberdasher"
Usage
Writing Decorators
Similar to draper, decorators inherit from Haberdasher::Decorator
, live in your app/decorators
directory, and are named for the model that they decorate:
class ArticleDecorator < Haberdasher::Decorator
end
Using Decorators
Use #decorate
For the time being, explicitly #include
the Haberdasher::Decoratoratable
in your model:
class Article < ActiveRecord::Base
include Haberdasher::Decoratoratable
end
Or use the decorator explicitly without mixing any modules in
def show
@article = ArticleDecorator.new Article.find params[:id]
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request