Module: Pragma::Decorator::Pagination::Adapter Private
- Defined in:
- lib/pragma/decorator/pagination/adapter.rb,
lib/pragma/decorator/pagination/adapter/base.rb,
lib/pragma/decorator/pagination/adapter/kaminari.rb,
lib/pragma/decorator/pagination/adapter/will_paginate.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Adapters make pagination library-independent by providing support for multiple underlying libraries like Kaminari and will_paginate.
Defined Under Namespace
Classes: Base, Kaminari, NoAdapterError, WillPaginate
Constant Summary collapse
- SUPPORTED_ADAPTERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The list of supported adapters, in order of priority.
[Kaminari, WillPaginate].freeze
Class Method Summary collapse
-
.load_for(collection) ⇒ Adapter::Base
private
Loads the adapter for the given collection.
Class Method Details
.load_for(collection) ⇒ Adapter::Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads the adapter for the given collection.
This will try SUPPORTED_ADAPTERS in order until it finds an adapter that supports the collection. When the adapter is found, it will return a new instance of it.
26 27 28 29 30 31 32 33 34 |
# File 'lib/pragma/decorator/pagination/adapter.rb', line 26 def self.load_for(collection) adapter_klass = SUPPORTED_ADAPTERS.find do |klass| klass.supports?(collection) end fail NoAdapterError unless adapter_klass adapter_klass.new(collection) end |