Method: Scimitar::ResourcesController#index

Defined in:
app/controllers/scimitar/resources_controller.rb

#index(pagination_info, page_of_results, &block) ⇒ Object

GET (list)

Pass a Scimitar::Lists::Count object providing pagination data along with a page of results in “your” data domain as an Enumerable, along with a block. Renders as “list” result by calling your block with each of the results, allowing you to use something like Scimitar::Resources::Mixin#to_scim to convert to a SCIM representation.

pagination_info

A Scimitar::Lists::Count instance with #total set. See e.g. protected method #scim_pagination_info to assist with this.

page_of_results

An Enumerable single page of results.



44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/scimitar/resources_controller.rb', line 44

def index(pagination_info, page_of_results, &block)
  render(json: {
    schemas: [
        'urn:ietf:params:scim:api:messages:2.0:ListResponse'
    ],
    totalResults: pagination_info.total,
    startIndex:   pagination_info.start_index,
    itemsPerPage: pagination_info.limit,
    Resources:    page_of_results.map(&block)
  })
end