18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/simple_auth/action_controller.rb', line 18
def install_simple_auth_scope(scope)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{scope}_session
@#{scope}_session ||= Session.create(scope: :#{scope}, session: session)
end
def current_#{scope}
#{scope}_session.record
end
def #{scope}_logged_in?
current_#{scope}.present?
end
RUBY
define_method "authorized_#{scope}?" do
true
end
define_method "require_logged_#{scope}" do
simple_auth_require_logged_scope(scope)
end
define_method "redirect_logged_#{scope}" do
simple_auth_redirect_logged_scope(scope)
end
end
|