-
-
Save jcasimir/3190890 to your computer and use it in GitHub Desktop.
overriding DecoratedEnumerableProxy
This file contains hidden or 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 InvoicesController < ApplicationController | |
def index | |
respond_with id InvoicesDecorator.new(invoices, InvoiceDecorator) | |
end | |
end | |
class InvoicesDecorator < Draper::DecoratedEnumerableProxy | |
def method_regardless_of_invoices_empty_or_not | |
"yay" | |
end | |
end | |
class InvoiceDecorator < ApplicationDecorator | |
decorates :invoice | |
#normal stuffs | |
end | |
#index.html.haml | |
#invoices | |
= invoices.method_regardless_of_invoices_empty_or_not | |
- invoices.each do |invoice| | |
= invoice.amount |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, that makes sense to me. It's been awhile since I looked at the
DecoratedEnumerableProxy
though.