Class: Scimitar::ResourceTypesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/scimitar/resource_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
# File 'app/controllers/scimitar/resource_types_controller.rb', line 5

def index
  resource_types = Scimitar::Engine.resources.map do |resource|
    resource.resource_type(scim_resource_type_url(name: resource.resource_type_id))
  end

  render json: resource_types
end

#showObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/scimitar/resource_types_controller.rb', line 13

def show
  resource_types = Scimitar::Engine.resources.reduce({}) do |hash, resource|
    hash[resource.resource_type_id] = resource.resource_type(scim_resource_type_url(name: resource.resource_type_id))
    hash
  end

  resource_type = resource_types[params[:name]]

  if resource_type.nil?
    raise Scimitar::NotFoundError.new(params[:name])
  else
    render json: resource_type
  end
end