Class: DeviseScim::GroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/devise_scim/groups_controller.rb

Overview

Groups controller delegates all model interaction to the host app’s ScimAdapter subclass. The gem handles the SCIM protocol layer; the adapter handles group lifecycle.

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
# File 'app/controllers/devise_scim/groups_controller.rb', line 11

def create
  scim_g  = Scim::Group.from_h(parsed_body)
  adapter = scim_adapter_for(nil, scim_g)
  adapter.handle_group_create
  render_scim(adapter.group_to_scim, status: :created)
rescue NotImplementedError => e
  render_scim(Scim::Error.server_error(e.message), status: :internal_server_error)
end

#destroyObject



46
47
48
49
50
51
# File 'app/controllers/devise_scim/groups_controller.rb', line 46

def destroy
  scim_g  = build_scim_group_for_id(params[:id])
  adapter = scim_adapter_for(nil, scim_g)
  adapter.handle_group_destroy
  head :no_content
end

#indexObject



7
8
9
# File 'app/controllers/devise_scim/groups_controller.rb', line 7

def index
  render_scim(Scim::ListResponse.new(resources: []))
end

#replaceObject



28
29
30
31
32
33
34
35
# File 'app/controllers/devise_scim/groups_controller.rb', line 28

def replace
  scim_g  = Scim::Group.from_h(parsed_body)
  adapter = scim_adapter_for(nil, scim_g)
  adapter.handle_group_update
  render_scim(adapter.group_to_scim)
rescue NotImplementedError => e
  render_scim(Scim::Error.server_error(e.message), status: :internal_server_error)
end

#showObject



20
21
22
23
24
25
26
# File 'app/controllers/devise_scim/groups_controller.rb', line 20

def show
  scim_g  = build_scim_group_for_id(params[:id])
  adapter = scim_adapter_for(nil, scim_g)
  render_scim(adapter.group_to_scim)
rescue NotImplementedError => e
  render_scim(Scim::Error.server_error(e.message), status: :internal_server_error)
end

#updateObject



37
38
39
40
41
42
43
44
# File 'app/controllers/devise_scim/groups_controller.rb', line 37

def update
  scim_g  = Scim::Group.from_h(parsed_body)
  adapter = scim_adapter_for(nil, scim_g)
  adapter.handle_group_update
  render_scim(adapter.group_to_scim)
rescue NotImplementedError => e
  render_scim(Scim::Error.server_error(e.message), status: :internal_server_error)
end