Created
October 14, 2012 04:51
-
-
Save stevenharman/3887381 to your computer and use it in GitHub Desktop.
Hacking "presenters" into Draper.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CellaredBrewPresenter < ApplicationDecorator | |
decorates :brew | |
def initialize(args) | |
@cellar = args.delete(:cellar) | |
super(args.delete(:brew), args) | |
end | |
def beers | |
@beers ||= cellar.beers_for(brew) | |
end | |
def beer_count | |
beers.size | |
end | |
private | |
attr_reader :cellar | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment