Module: ActiveAdmin::ResourceController::Decorators

Included in:
ActiveAdmin::ResourceController
Defined in:
lib/active_admin/resource_controller/decorators.rb

Defined Under Namespace

Classes: Wrapper

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.undecorate(resource) ⇒ Object (protected)


20
21
22
23
24
25
26
# File 'lib/active_admin/resource_controller/decorators.rb', line 20

def self.undecorate(resource)
  if resource.respond_to?(:decorated?) && resource.decorated?
    resource.model
  else
    resource
  end
end

Instance Method Details

#apply_collection_decorator(collection) ⇒ Object (protected)


12
13
14
15
16
17
18
# File 'lib/active_admin/resource_controller/decorators.rb', line 12

def apply_collection_decorator(collection)
  if decorate?
    collection_decorator.decorate collection, with: decorator_class
  else
    collection
  end
end

#apply_decorator(resource) ⇒ Object (protected)


8
9
10
# File 'lib/active_admin/resource_controller/decorators.rb', line 8

def apply_decorator(resource)
  decorate? ? decorator_class.new(resource) : resource
end