Created
March 14, 2013 15:46
-
-
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.
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
| 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 |
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
| ... | |
| <%= 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