Class: Apiwork::Adapter::Standard::Capability::Pagination::APIBuilder

Inherits:
Capability::API::Base show all
Defined in:
lib/apiwork/adapter/standard/capability/pagination/api_builder.rb

Instance Attribute Summary

Attributes inherited from Capability::API::Base

#options, #scope

Attributes inherited from Builder::API::Base

#data_type

Instance Method Summary collapse

Methods inherited from Capability::API::Base

#configured, #initialize

Methods inherited from Builder::API::Base

#enum, #enum?, #initialize, #object, #type?, #union

Constructor Details

This class inherits a constructor from Apiwork::Adapter::Capability::API::Base

Instance Method Details

#buildObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/apiwork/adapter/standard/capability/pagination/api_builder.rb', line 9

def build
  return unless scope.index_actions?

  if configured(:strategy).include?(:offset)
    object(:offset_pagination) do |object|
      object.integer(:current)
      object.integer?(:next, nullable: true)
      object.integer?(:prev, nullable: true)
      object.integer(:total)
      object.integer(:items)
    end
  end

  return unless configured(:strategy).include?(:cursor)

  object(:cursor_pagination) do |object|
    object.string?(:next, nullable: true)
    object.string?(:prev, nullable: true)
  end
end