Skip to content

Service ColumnsBuilder

Vladislav Trotsenko edited this page Sep 30, 2019 · 1 revision

Synopsis

Auxiliary service for performing validation dependencies for filtering/sorting operations. Build collection with Api::V1::Lib::Service::JsonApi::Column instances.

ctx[:available_columns] = Api::V1::Lib::Service::JsonApi::ColumnsBuilder.call(
  [
    { name: :attr_1, filterable: true, sortable: false }, # by default type: :string
    { name: :attr_2, type: :number, filterable: true, sortable: true }
  ]
)

=>

[
  <struct Api::V1::Lib::Service::JsonApi::Column name=:attr_1, type=:string, sortable=false, filterable=true>,
  <struct Api::V1::Lib::Service::JsonApi::Column name=:attr_2, type=:number, sortable=true, filterable=true>
]
Clone this wiki locally