Class: ActionView::CollectionRenderer::PreloadCollectionIterator
- Inherits:
-
SameCollectionIterator
- Object
- CollectionIterator
- SameCollectionIterator
- ActionView::CollectionRenderer::PreloadCollectionIterator
- Defined in:
- actionview/lib/action_view/renderer/collection_renderer.rb
Overview
:nodoc:
Instance Method Summary collapse
- #each_with_info ⇒ Object
- #from_collection(collection) ⇒ Object
-
#initialize(collection, path, variables, relation) ⇒ PreloadCollectionIterator
constructor
A new instance of PreloadCollectionIterator.
- #preload! ⇒ Object
Methods inherited from CollectionIterator
Methods included from Enumerable
#as_json, #compact_blank, #exclude?, #excluding, #in_order_of, #including, #index_by, #index_with, #many?, #maximum, #minimum, #pick, #pluck, #sole
Constructor Details
#initialize(collection, path, variables, relation) ⇒ PreloadCollectionIterator
Returns a new instance of PreloadCollectionIterator.
79 80 81 82 83 |
# File 'actionview/lib/action_view/renderer/collection_renderer.rb', line 79 def initialize(collection, path, variables, relation) super(collection, path, variables) relation.skip_preloading! unless relation.loaded? @relation = relation end |
Instance Method Details
#each_with_info ⇒ Object
89 90 91 92 93 |
# File 'actionview/lib/action_view/renderer/collection_renderer.rb', line 89 def each_with_info return super unless block_given? preload! super end |
#from_collection(collection) ⇒ Object
85 86 87 |
# File 'actionview/lib/action_view/renderer/collection_renderer.rb', line 85 def from_collection(collection) self.class.new(collection, @path, @variables, @relation) end |
#preload! ⇒ Object
95 96 97 |
# File 'actionview/lib/action_view/renderer/collection_renderer.rb', line 95 def preload! @relation.preload_associations(@collection) end |