Sha256: 4299df836f73189f06677b2c80c823fe1057be2f00fa89c12da775fe5783f006

Contents?: true

Size: 1.57 KB

Versions: 25

Compression:

Stored size: 1.57 KB

Contents

# controller
require 'role_authorization/controller/mapper'
require 'role_authorization/controller/ruleset'
require 'role_authorization/controller/allow_group'
require 'role_authorization/controller'

# roles
require 'role_authorization/roles/manager'
require 'role_authorization/roles/role'
require 'role_authorization/roles/role_group'
require 'role_authorization/roles'

# active record
require 'role_authorization/active_record'

# rules
require 'role_authorization/rules'
require 'role_authorization/rules/rule'
require 'role_authorization/rules/defaults'

# exts
require 'role_authorization/user'

require 'rails/role_authorization' if defined?(Rails)

module RoleAuthorization
  module ClassMethods
    def load_rules
      # load default rules
      Dir.chdir(File.dirname(__FILE__)) do
        Dir["rules/*.rb"].each do |rule_definition|
          require "#{File.dirname(__FILE__)}/#{rule_definition}"
        end
      end

      # load application rules
      Dir.chdir(Rails.root) do
        Dir["lib/rules/*.rb"].each do |rule_definition|
          require "#{Rails.root}/#{rule_definition}"
        end
      end

      # load allow groups
      Dir.chdir(Rails.root) do
        Dir["lib/allow_groups/*.rb"].each do |allow_group|
          require "#{Rails.root}/#{allow_group}"
        end
      end
    end

    def enable_view_security
      require 'role_authorization/view_security'
      unless ActionView::Base.instance_methods.include? :link_to_or_show
        ActionView::Base.class_eval { include RoleAuthorization::ViewSecurity }
      end
    end
  end
  extend ClassMethods
end


Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
role_authorization-0.4.5 lib/role_authorization.rb
role_authorization-0.4.4 lib/role_authorization.rb
role_authorization-0.4.3 lib/role_authorization.rb
role_authorization-0.4.2 lib/role_authorization.rb
role_authorization-0.4.1 lib/role_authorization.rb