module ActiveAdmin::ResourceController::Collection::Scoping

def active_admin_collection

def active_admin_collection
  scope_current_collection(super)
end

def collection_before_scope

def collection_before_scope
  @collection_before_scope
end

def current_scope

def current_scope
  @current_scope ||= if params[:scope]
    active_admin_config.get_scope_by_id(params[:scope]) if params[:scope]
  else
    active_admin_config.default_scope
  end
end

def scope_current_collection(chain)

def scope_current_collection(chain)
  @collection_before_scope = chain
  if current_scope
    scope_chain(current_scope, chain)
  else
    chain
  end
end