class Squall::Role

OnApp Role

Public Instance Methods

create(options = {}) click to toggle source

Public: Create a new Role

options - Params for creating the roles:

:label          - Label for the role
:permission_ids - An array of permission ids granted to the role.

Example

create label: 'Admin'
# File lib/squall/role.rb, line 31
def create(options = {})
  request(:post, '/roles.json', default_params(options))
end
delete(id) click to toggle source

Public: Delete a Role.

id - ID of the role

Returns a Hash.

# File lib/squall/role.rb, line 54
def delete(id)
  request(:delete, "/roles/#{id}.json")
end
edit(id, options = {}) click to toggle source

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.

# File lib/squall/role.rb, line 45
def edit(id, options = {})
  request(:put, "/roles/#{id}.json", default_params(options))
end
list() click to toggle source

Public: Lists all roles.

Returns an Array.

# File lib/squall/role.rb, line 7
def list
  response = request(:get, '/roles.json')
  response.collect { |role| role['role']}
end
permissions() click to toggle source

Public: Lists all permissions available.

Returns an Array.

# File lib/squall/role.rb, line 61
def permissions
  response = request(:get, '/permissions.json')
  response.collect { |perm| perm['permission'] }
end
show(id) click to toggle source

Public: Show info for the given role.

id - ID of the role

Returns a Hash.

# File lib/squall/role.rb, line 17
def show(id)
  response = request(:get, "/roles/#{id}.json")
  response["role"]
end