Class: ActiveAdmin::ResourceController::Decorators::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/active_admin/resource_controller/decorators.rb

Class Method Summary collapse

Class Method Details

.find_collection_decorator(decorator) ⇒ Object



71
72
73
74
75
76
77
# File 'app/controllers/active_admin/resource_controller/decorators.rb', line 71

def self.find_collection_decorator(decorator)
  if decorator.respond_to?(:collection_decorator_class)
    decorator.collection_decorator_class
  else
    CollectionDecorator
  end
end

.wrap(decorator) ⇒ Object



55
56
57
58
59
# File 'app/controllers/active_admin/resource_controller/decorators.rb', line 55

def self.wrap(decorator)
  collection_decorator = find_collection_decorator(decorator)
  name = "#{collection_decorator.name} of #{decorator} + ActiveAdmin"
  @cache[name] ||= wrap! collection_decorator, name
end

.wrap!(parent, name) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'app/controllers/active_admin/resource_controller/decorators.rb', line 61

def self.wrap!(parent, name)
  ::Class.new parent do
    delegate :reorder, :page, :current_page, :total_pages, :limit_value,
             :total_count, :offset, :to_key, :group_values,
             :except, :find_each, :ransack, to: :object

    define_singleton_method(:name) { name }
  end
end