Class: Squall::Role
Overview
OnApp Role
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(options = {}) ⇒ Object
Public: Create a new Role.
-
#delete(id) ⇒ Object
Public: Delete a Role.
-
#edit(id, options = {}) ⇒ Object
Public: Edit a Role.
-
#list ⇒ Object
Public: Lists all roles.
-
#permissions ⇒ Object
Public: Lists all permissions available.
-
#show(id) ⇒ Object
Public: Show info for the given role.
Methods inherited from Base
#check_config, #default_params, #key_for_class, #request
Instance Method Details
#create(options = {}) ⇒ Object
Public: Create a new Role
options - Params for creating the roles:
:label - Label for the role
:permission_ids - An array of ids granted to the role.
Example
create label: 'Admin'
31 32 33 |
# File 'lib/squall/role.rb', line 31 def create( = {}) request(:post, '/roles.json', default_params()) end |
#delete(id) ⇒ Object
Public: Delete a Role.
id - ID of the role
Returns a Hash.
54 55 56 |
# File 'lib/squall/role.rb', line 54 def delete(id) request(:delete, "/roles/#{id}.json") end |
#edit(id, options = {}) ⇒ Object
Public: Edit a Role.
id - ID of the role options - Params for editing the roles, see ‘#create`
Example
edit 1, label: 'myrole', permission_ids: [1, 3]
Returns a Hash.
45 46 47 |
# File 'lib/squall/role.rb', line 45 def edit(id, = {}) request(:put, "/roles/#{id}.json", default_params()) end |
#list ⇒ Object
Public: Lists all roles.
Returns an Array.
7 8 9 10 |
# File 'lib/squall/role.rb', line 7 def list response = request(:get, '/roles.json') response.collect { |role| role['role']} end |
#permissions ⇒ Object
Public: Lists all permissions available.
Returns an Array.
61 62 63 64 |
# File 'lib/squall/role.rb', line 61 def response = request(:get, '/permissions.json') response.collect { |perm| perm['permission'] } end |
#show(id) ⇒ Object
Public: Show info for the given role.
id - ID of the role
Returns a Hash.
17 18 19 20 |
# File 'lib/squall/role.rb', line 17 def show(id) response = request(:get, "/roles/#{id}.json") response["role"] end |