78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/rules_engine/controller_users.rb', line 78
def define_access_level name, access_level
(class << self; self end).instance_eval do
USER_ACCESS_LEVEL << [name.to_s.titleize, access_level]
end
(class << self; self end).instance_eval do
define_method "#{name}_access_level" do
access_level
end
end
define_method "#{name}?" do
logged_in? && current_user.access_level >= access_level
end
define_method "#{name}_access_required" do
login_required
return unless logged_in?
unless current_user.access_level >= access_level
flash[:error]="This page requires #{name} access"
user_access_denied
end
end
self.send :helper_method, "#{name}?"
end
|