Created
April 4, 2012 13:41
-
-
Save davelyon/2301113 to your computer and use it in GitHub Desktop.
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 ApplicationController < ActionController::Base | |
def self.present as, from, klass | |
if from.to_s.singularize == from.to_s | |
expose(as) { klass.new send(from) } | |
else | |
expose(as) { send(from).map { |orig| klass.new(orig) } } | |
end | |
end | |
end | |
# In another controller... | |
expose(:people) | |
present(:pretty_people, :people, PrettyPeoplePresenter) | |
# In your view | |
- pretty_people.each do |pretty| | |
render :pretty_pretty, pretty | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment