forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
Implement a custom decorator
Zinovyev Ivan edited this page Oct 31, 2017
·
4 revisions
The ActiveAdmin's decoration itegration has dependencies on Draper gem.
If you want to use another decorator, the #decorate
method should be implemented there. And it should be able to accept colletions as an argument. Here's an example for the SimpleDelegator
class:
class SimpleDelegator
class << self
def decorate(*args)
object = args[0]
if is_collection?(object)
object.map { |o| new(o) }
else
new(object)
end
end
def is_collection?(object)
object.is_a?(Enumerable)
end
end
end