146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/ae_users.rb', line 146
def acts_as_permissioned(options = {})
has_many :permissions, :as => :permissioned, :dependent => :destroy, :include => [:person, :role, :permissioned]
cattr_accessor :permission_names
self.permission_names = options[:permission_names] || [:show, :edit, :destroy]
self.permission_names = self.permission_names.collect do |perm|
perm.to_s
end
if not self.permission_names.include? "change_permissions"
self.permission_names.push "change_permissions"
end
self.permission_names.each do |perm|
define_method("permit_#{perm}?") do |person|
self.permitted?(person, perm)
end
end
AeUsers.add_permissioned_class(self)
extend AeUsers::Acts::Permissioned::SingletonMethods
include AeUsers::Acts::Permissioned::InstanceMethods
end
|