Class: Gitlab::Pagination::OffsetHeaderBuilder
- Inherits:
-
Object
- Object
- Gitlab::Pagination::OffsetHeaderBuilder
- Defined in:
- lib/gitlab/pagination/offset_header_builder.rb
Instance Attribute Summary collapse
-
#next_page ⇒ Object
readonly
Returns the value of attribute next_page.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#prev_page ⇒ Object
readonly
Returns the value of attribute prev_page.
-
#request_context ⇒ Object
readonly
Returns the value of attribute request_context.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
- #execute(exclude_total_headers: false, data_without_counts: false) ⇒ Object
-
#initialize(request_context:, per_page:, page:, next_page:, prev_page: nil, total: nil, total_pages: nil, params: nil) ⇒ OffsetHeaderBuilder
constructor
A new instance of OffsetHeaderBuilder.
Constructor Details
#initialize(request_context:, per_page:, page:, next_page:, prev_page: nil, total: nil, total_pages: nil, params: nil) ⇒ OffsetHeaderBuilder
Returns a new instance of OffsetHeaderBuilder.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 10 def initialize(request_context:, per_page:, page:, next_page:, prev_page: nil, total: nil, total_pages: nil, params: nil) @request_context = request_context @per_page = per_page @page = page @next_page = next_page @prev_page = prev_page @total = total @total_pages = total_pages @params = params end |
Instance Attribute Details
#next_page ⇒ Object (readonly)
Returns the value of attribute next_page.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def next_page @next_page end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def per_page @per_page end |
#prev_page ⇒ Object (readonly)
Returns the value of attribute prev_page.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def prev_page @prev_page end |
#request_context ⇒ Object (readonly)
Returns the value of attribute request_context.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def request_context @request_context end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def total @total end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
6 7 8 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 6 def total_pages @total_pages end |
Instance Method Details
#execute(exclude_total_headers: false, data_without_counts: false) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gitlab/pagination/offset_header_builder.rb', line 21 def execute(exclude_total_headers: false, data_without_counts: false) header 'X-Per-Page', per_page.to_s header 'X-Page', page.to_s header 'X-Next-Page', next_page.to_s header 'X-Prev-Page', prev_page.to_s header 'Link', pagination_links(data_without_counts) return if exclude_total_headers || data_without_counts header 'X-Total', total.to_s header 'X-Total-Pages', total_pages.to_s end |