Class: Uchi::Pagy

Inherits:
Object
  • Object
show all
Extended by:
Configurable
Includes:
Linkable, Loader
Defined in:
lib/uchi/pagy.rb,
lib/uchi/pagy/classes/request.rb,
lib/uchi/pagy/modules/console.rb,
lib/uchi/pagy/classes/exceptions.rb,
lib/uchi/pagy/classes/offset/offset.rb,
lib/uchi/pagy/toolbox/helpers/loader.rb,
lib/uchi/pagy/toolbox/helpers/page_url.rb,
lib/uchi/pagy/toolbox/paginators/method.rb,
lib/uchi/pagy/toolbox/paginators/offset.rb,
lib/uchi/pagy/modules/abilities/linkable.rb,
lib/uchi/pagy/modules/abilities/rangeable.rb,
lib/uchi/pagy/modules/abilities/shiftable.rb,
lib/uchi/pagy/modules/abilities/configurable.rb

Overview

Top superclass: it defines only what's common to all the subclasses

Defined Under Namespace

Modules: Configurable, Console, Linkable, Loader, OffsetPaginator, Rangeable, Shiftable Classes: InternalError, JsonapiReservedParamError, Offset, OptionError, RailsI18nLoadError, RangeError, Request

Constant Summary collapse

VERSION =
'43.0.0.rc4'
ROOT =
Pathname.new(__dir__).parent.freeze
DEFAULT =
{ limit: 20, limit_key: 'limit', page_key: 'page' }.freeze
PAGE_TOKEN =
'P '
LIMIT_TOKEN =
'L '
LABEL_TOKEN =
'L'
A_TAG =
'<a style="display: none;">#</a>'
Method =

Defines the pagy method. Include in the app controller/view.

Module.new do
  protected

  define_method :pagy do |paginator = :offset, collection, **options|
    Pagy.const_get(paginators[paginator]).paginate(self, collection, **Pagy.options, **options)
  end
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Configurable

dev_tools, sync_javascript, translate_with_the_slower_i18n_gem!

Instance Attribute Details

#inObject (readonly)

Returns the value of attribute in.



32
33
34
# File 'lib/uchi/pagy.rb', line 32

def in
  @in
end

#limitObject (readonly)

Returns the value of attribute limit.



32
33
34
# File 'lib/uchi/pagy.rb', line 32

def limit
  @limit
end

#nextObject (readonly)

Returns the value of attribute next.



32
33
34
# File 'lib/uchi/pagy.rb', line 32

def next
  @next
end

#optionsObject (readonly)

Returns the value of attribute options.



32
33
34
# File 'lib/uchi/pagy.rb', line 32

def options
  @options
end

#pageObject (readonly)

Returns the value of attribute page.



32
33
34
# File 'lib/uchi/pagy.rb', line 32

def page
  @page
end

Class Method Details

.optionsObject



26
# File 'lib/uchi/pagy.rb', line 26

def self.options = @options ||= {}

Instance Method Details

#page_url(page) ⇒ Object

Return the page url for any page :nocov:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/uchi/pagy/toolbox/helpers/page_url.rb', line 7

def page_url(page, **)
  case page
  when :first
    compose_page_url(nil, **)
  when :current
    compose_page_url(@page, **) if @page
  when :previous
    compose_page_url(@previous, **) if @previous
  when :next
    compose_page_url(@next, **) if @next
  when :last
    compose_page_url(@last, **) if @last
  when Integer, String
    compose_page_url(page, **)
  end
end