Class: Xing::Serializers::PagedIndex

Inherits:
Base
  • Object
show all
Includes:
Paged
Defined in:
lib/xing/serializers/paged_index.rb

Overview

Serializes the reference index of a long paginated list. We assume the interface provided by Kaminari: the object to be serialized needs to respond to:

current_page, limit_value, total_pages, total_count, each(and various
Enumerable methods)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paged

#first_link, #last_link, #links, #page_link, #template_link, #total_pages

Methods inherited from Base

#as_json_with_wrap, #links, #root, #routes

Class Method Details

.total_called(name) ⇒ Object



15
16
17
18
# File 'lib/xing/serializers/paged_index.rb', line 15

def self.total_called(name)
  attributes name
  alias_method name, :total_items
end

Instance Method Details

#per_pageObject



26
27
28
# File 'lib/xing/serializers/paged_index.rb', line 26

def per_page
  object.limit_value
end

Raises:

  • (NotImplementedError)


30
31
32
33
# File 'lib/xing/serializers/paged_index.rb', line 30

def self_link
  raise NotImplementedError,
    "subclasses of Xing::Serializers::PagedIndex must override self_link to provide a path URL to themselves"
end

#total_itemsObject



22
23
24
# File 'lib/xing/serializers/paged_index.rb', line 22

def total_items
  object.total_count
end