Skip to content

Instantly share code, notes, and snippets.

@chewbranca
Created January 24, 2011 22:26
Show Gist options
  • Save chewbranca/794104 to your computer and use it in GitHub Desktop.
Save chewbranca/794104 to your computer and use it in GitHub Desktop.
class ViewObject
include Enumerable
extend Forwardable
def_delegators :@views, :<<, :[], :[]=, :last, :first, :push
def initialize controller
@controller = controller
@views = []
end
def each
@views.each {|view| yield view }
end
def render
@controller.send(:render, :template => "shared/view_object_template", :locals => { :view_object => self })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment