Skip to content

Instantly share code, notes, and snippets.

@IanWhitney
Created March 14, 2013 15:46
Show Gist options
  • Select an option

  • Save IanWhitney/5162485 to your computer and use it in GitHub Desktop.

Select an option

Save IanWhitney/5162485 to your computer and use it in GitHub Desktop.
Required methods for a custom enumerable if you want to pass it to PartialRenderer.
require 'forwardable'
class CustomEnum
extend Forwardable
include Enumerable
def_delegators :@collection, :size, :each, :blank?
attr_accessor :collection
def initialize()
self.collection = []
end
def to_ary
self
end
end
...
<%= render :partial => "warning", :collection => @foo.custom_collection %>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment