CanTango Roles

Roles and Role groups extension for CanTango

Status: Dec 9, 2011

Most specs except those for Permits have been completed and demonstrates that the functionality works as it should.

Ability helper

  • Ability::Helper
    • Role
    • RoleGroup

These modules are typically included into an Ability in order to access the roles of the ability subject, typically a user (or in rare cases an account).

The Role module has a #roles method which returns the role list of the subject. The RoleGroup module has a #role_groups method which returns the role group list of the subject.

Configuration Registry

Roles and RoleGroups configuration via a Registry.

Roles configuration:

CanTango.config do |config|
  config.roles do |roles|
    roles.register :admin, :guest, :basic
    roles.system = :simple_roles
    roles.exclude :admin # filter
  end

Role groups configuration:

CanTango.config do |config|
  config.roles_groups do |role_groups|
    role_groups.register :editors, :publishers
    role_groups.system = :troles
    role_groups.only :editors # filter
  end
end

Permits

Role and RoleGroup Permits for the Permits engine Ability executor.

Permit Generators

Role and RoleGroup Permit Generators

rails g cantango:role_permit admin

Role group

rails g cantango:role_permit admin --group

Filters

Role and RoleGroup filters can be used to filter out specific Role and RoleGroup Permits.

Helpers

Role and RoleGroup helper methods which can be reused in various places, such as Ability executors, Permits etc.

Contributing to cantango-roles

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2011 Kristian Mandrup. See LICENSE.txt for further details.