class ActiveAdmin::CollectionDecorator
This class decorates a collection of objects delegating mehods to behave like an Array. It’s used to decouple ActiveAdmin
from Draper and thus being able to use PORO decorators as well.
It’s implementation is heavily based on the Draper::CollectionDecorator github.com/drapergem/draper/blob/aaa06bd2f1e219838b241a5534e7ca513edd1fe2/lib/draper/collection_decorator.rb
Attributes
decorator_class[R]
@return [Class] the decorator class used to decorate each item, as set by {#initialize}.
object[R]
@return the collection being decorated.
Public Class Methods
new(object, with:)
click to toggle source
# File lib/active_admin/collection_decorator.rb, line 19 def initialize(object, with:) @object = object @decorator_class = with end
Also aliased as: decorate
Public Instance Methods
decorated_collection()
click to toggle source
# File lib/active_admin/collection_decorator.rb, line 28 def decorated_collection @decorated_collection ||= object.map { |item| decorator_class.new(item) } end