Class: DeviseScim::Scim::ListResponse
- Inherits:
-
Object
- Object
- DeviseScim::Scim::ListResponse
- Defined in:
- lib/devise_scim/scim/list_response.rb
Instance Method Summary collapse
-
#initialize(resources:, total_results: nil, start_index: 1, items_per_page: 100) ⇒ ListResponse
constructor
A new instance of ListResponse.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(resources:, total_results: nil, start_index: 1, items_per_page: 100) ⇒ ListResponse
Returns a new instance of ListResponse.
10 11 12 13 14 15 |
# File 'lib/devise_scim/scim/list_response.rb', line 10 def initialize(resources:, total_results: nil, start_index: 1, items_per_page: 100) @resources = resources @total_results = total_results || resources.size @start_index = start_index @items_per_page = items_per_page end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/devise_scim/scim/list_response.rb', line 17 def to_h { "schemas" => [LIST_RESPONSE_SCHEMA], "totalResults" => @total_results, "startIndex" => @start_index, "itemsPerPage" => @items_per_page, "Resources" => @resources.map { |r| r.respond_to?(:to_h) ? r.to_h : r } } end |
#to_json ⇒ Object
27 28 29 |
# File 'lib/devise_scim/scim/list_response.rb', line 27 def to_json(*) to_h.to_json end |