about summary refs log tree commit diff
path: root/app/controllers/api/v1/timelines/base_controller.rb
blob: 4eb29e74a21a4c54150f33f1d31c3ceae27485c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Api::V1::Timelines
  class BaseController < ApiController
    respond_to :json
    after_action :insert_pagination_headers, unless: -> { @statuses.empty? }

    private

    def cache_collection(raw)
      super(raw, Status)
    end

    def pagination_params(core_params)
      params.permit(:local, :limit).merge(core_params)
    end

    def insert_pagination_headers
      set_pagination_headers(next_path, prev_path)
    end

    def next_path
      raise 'Override in child controllers'
    end

    def prev_path
      raise 'Override in child controllers'
    end
  end
end