public
Description: This plugin provides a flexible way to add authorization to Rails.
Homepage: http://www.writertopia.com/developers/authorization
Clone URL: git://github.com/DocSavage/rails-authorization-plugin.git
100644 30 lines (25 sloc) 1.115 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require File.dirname(__FILE__) + '/lib/authorization'
 
ActionController::Base.send( :include, Authorization::Base )
ActionView::Base.send( :include, Authorization::Base::ControllerInstanceMethods )
 
# You can perform authorization at varying degrees of complexity.
# Choose a style of authorization below (see README.txt) and the appropriate
# mixin will be used for your app.
 
# When used with the auth_test app, we define this in config/environment.rb
# AUTHORIZATION_MIXIN = "hardwired"
if not Object.constants.include? "AUTHORIZATION_MIXIN"
  AUTHORIZATION_MIXIN = "object roles"
end
 
case AUTHORIZATION_MIXIN
  when "hardwired"
    require File.dirname(__FILE__) + '/lib/publishare/hardwired_roles'
    ActiveRecord::Base.send( :include,
      Authorization::HardwiredRoles::UserExtensions,
      Authorization::HardwiredRoles::ModelExtensions
    )
  when "object roles"
    require File.dirname(__FILE__) + '/lib/publishare/object_roles_table'
    ActiveRecord::Base.send( :include,
      Authorization::ObjectRolesTable::UserExtensions,
      Authorization::ObjectRolesTable::ModelExtensions
    )
end