Module: Xing::Serializers::Paged

Included in:
PagedIndex, PagedList
Defined in:
lib/xing/serializers/paged.rb

Instance Method Summary collapse

Instance Method Details



14
15
16
# File 'lib/xing/serializers/paged.rb', line 14

def first_link
  page_link({page: 1})
end


18
19
20
# File 'lib/xing/serializers/paged.rb', line 18

def last_link
  page_link({page: total_pages})
end


26
27
28
29
30
31
32
33
# File 'lib/xing/serializers/paged.rb', line 26

def links
  {
    :self => self_link,
    :first => first_link,
    :last => last_link,
    :template => template_link
  }
end


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

def page_link(options)
  template_link.expand(options)
end

Raises:

  • (NotImplementedError)


3
4
5
6
7
8
# File 'lib/xing/serializers/paged.rb', line 3

def template_link
  raise NotImplementedError,
    "subclasses of Xing::Serializers::PagedList must override template_link to provide a path URL template with a single :page field\n" +
    "usually you can do something like my_resource_path_rfc6570 (sometimes you'll need to also call .partial_expand)\n\n" +
    "If you prefer, you can return nil from template_link and override page_link to do something else."
end

#total_pagesObject



10
11
12
# File 'lib/xing/serializers/paged.rb', line 10

def total_pages
  object.total_pages
end