Skip to content

Macro::LinksBuilder

Vladislav Trotsenko edited this page Sep 27, 2019 · 2 revisions

Synopsis

Provides to proxy resource path to Service::JsonApi::Paginator and sets composed links into context follow Jsonapi specification. Dependent from Api::V1::Lib::Operation::Pagination.

Examples of usage

resource_path should be an existing url_helper (Rails.application.routes.url_helpers)

Assign links into context without resource_name_id

class SomeOperation < ApplicationOperation
  step :set_model
  step Subprocess(Api::V1::Lib::Operation::Pagination) # sets ctx[:pagy]
  step Macro::LinksBuilder(resource_path: :some_path)
  step Macro::Renderer()
end

Assign links into context with resource_name_id

class SomeOperation < ApplicationOperation
  step :set_model
  step Subprocess(Api::V1::Lib::Operation::Pagination) # sets ctx[:pagy]
  step Macro::LinksBuilder(resource_path: :some_path, ids: %i[resource_name_id])
  step Macro::Renderer()
end
Clone this wiki locally