Sha256: 93d671d213781d0b8adc2a64c78a1a6a682a6a871769e644aa54485c5e52699b

Contents?: true

Size: 896 Bytes

Versions: 7

Compression:

Stored size: 896 Bytes

Contents

module Xing::Serializers
  module Paged
    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

    def total_pages
      object.total_pages
    end

    def first_link
      page_link({page: 1})
    end

    def last_link
      page_link({page: total_pages})
    end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
xing-backend-1.0.0.pre.beta lib/xing/serializers/paged.rb
xing-backend-0.0.25 lib/xing/serializers/paged.rb
xing-backend-0.0.23 lib/xing/serializers/paged.rb
xing-backend-0.0.22 lib/xing/serializers/paged.rb
xing-backend-0.0.21 lib/xing/serializers/paged.rb
xing-backend-0.0.20 lib/xing/serializers/paged.rb
xing-backend-0.0.19 lib/xing/serializers/paged.rb