Module: TinyCore::Controllers::Application
- Defined in:
- lib/tiny_core/controllers/application.rb
Class Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/tiny_core/controllers/application.rb', line 9
def method_missing(method, *args)
if method.to_s =~ /^can_.*\?$/
if current_user.send(method, *args)
yield if block_given?
true
else
false
end
elsif method.to_s =~ /^can_.*\!$/
if current_user.send(method.to_s.gsub(/\!$/, '?'), *args)
yield if block_given?
else
flash[:error] = t('flash.error.access_denied')
redirect_to root_path
false
end
else
super
end
end
|
Class Method Details
.included(receiver) ⇒ Object
4
5
6
|
# File 'lib/tiny_core/controllers/application.rb', line 4
def self.included(receiver)
receiver.helper_method :current_user_session, :current_user, :logged_in?
end
|