Sha256: 6825cff9e9d4afa7578b8804666f86983b1e64e0a914bcc692e3f03e0096e09a
Contents?: true
Size: 925 Bytes
Versions: 7
Compression:
Stored size: 925 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) unless defined? @@#{sym} @@#{sym} = Hash.new end def self.#{sym} @@#{sym} end def self.#{sym}=(obj) @@#{sym} = obj end def self.add_to_#{sym}(name, set = nil, &block) ruleset = self.#{sym} if block_given? ruleset[name] = RoleAuthorization::Mapper.new(self) 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
7 entries across 7 versions & 1 rubygems