13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/grant/grantable.rb', line 13
def grant(*args, &blk)
unless self.included_modules.include?(InstanceMethods)
include InstanceMethods
include Grant::Status
[:find, :create, :update, :destroy].each do |action|
send :class_attribute, "grantor_#{action}".to_sym
send "grantor_#{action}=".to_sym, Grant::Grantor.new(action) { false }
send "#{action == :find ? 'after' : 'before'}_#{action}".to_sym, "grant_#{action}".to_sym
end
end
Grant::Config.new(*args).actions.each do |action|
send "grantor_#{action}=".to_sym, Grant::Grantor.new(action, &blk)
end
end
|