Sha256: 6700c68c8dfe3414e6693fd966a4e63c35c137c4b556ab808a2efe5500cf38a4

Contents?: true

Size: 903 Bytes

Versions: 45

Compression:

Stored size: 903 Bytes

Contents

module RoleAuthorization
  module Ruleset
    def self.included(base)
      base.send :extend, ClassMethods
    end

    module ClassMethods

      def cattr_ruleset(*syms)
        syms.each do |sym|
          class_eval(<<-EOS, __FILE__, __LINE__ + 1)
            def self.#{sym}
              @@#{sym} ||= Hash.new
              @@#{sym}
            end

            def self.#{sym}=(obj)
              @@#{sym} ||= Hash.new
              @@#{sym} = obj
            end

            def self.add_to_#{sym}(name, set = nil, &block)
              ruleset = self.#{sym}
              if block_given?
                ruleset[name] = RoleAuthorization::Mapper.new
                ruleset[name].instance_eval(&block)
              elsif !set.nil?
                ruleset[name] = set
              end
              self.#{sym} = ruleset
            end
          EOS
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
role_authorization-0.9.6 lib/role_authorization/controller/ruleset.rb
role_authorization-0.9.5 lib/role_authorization/controller/ruleset.rb
role_authorization-0.9.4 lib/role_authorization/controller/ruleset.rb
role_authorization-0.9.3 lib/role_authorization/controller/ruleset.rb
role_authorization-0.9.2 lib/role_authorization/controller/ruleset.rb
role_authorization-0.9.1 lib/role_authorization/controller/ruleset.rb
role_authorization-0.9.0 lib/role_authorization/controller/ruleset.rb
role_authorization-0.6.2 lib/role_authorization/controller/ruleset.rb
role_authorization-0.6.1 lib/role_authorization/controller/ruleset.rb
role_authorization-0.6.0 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.9 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.8 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.7 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.6 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.5 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.4 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.3 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.2 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.1 lib/role_authorization/controller/ruleset.rb
role_authorization-0.5.0 lib/role_authorization/controller/ruleset.rb