Sha256: 121ed2523cf91945251b0033e789b52a5d497b653091efffb7eeb15edbc23520

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require 'acl9/version'
require 'acl9/model_extensions'
require 'acl9/controller_extensions'
require 'acl9/helpers'

module Acl9
  CONFIG = {
    :default_role_class_name    => 'Role',
    :default_subject_class_name => 'User',
    :default_subject_method     => :current_user,
    :default_association_name   => :role_objects,
    :default_join_table_name    => nil,
    :protect_global_roles       => true,
    :normalize_role_names       => true,
  }.freeze

  class Config < Struct.new(*CONFIG.keys )
    def [] k; send k.to_sym; end
    def []= k, v; send "#{k}=", v; end
    def reset!
      Acl9::CONFIG.each do |k,v|
        send "#{k}=", v
      end
    end

    def merge! h
      h.each { |k,v| self[k.to_sym] = v }
    end
  end

  @@config = Config.new( *CONFIG.values_at(*Config.members))

  mattr_reader :config

  def self.configure
    yield config
  end
end

ActiveRecord::Base.send(:include, Acl9::ModelExtensions)
AbstractController::Base.send :include, Acl9::ControllerExtensions
Acl9Helpers = Acl9::Helpers unless defined?(Acl9Helpers)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acl9-3.0.0 lib/acl9.rb
acl9-2.1.2 lib/acl9.rb
acl9-2.1.1 lib/acl9.rb