Module: Nyauth::ApplicationHelper
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
3
4
5
6
7
8
9
10
11
|
# File 'app/helpers/nyauth/application_helper.rb', line 3
def method_missing(method, *args, &block)
if method =~ /(.+)_path_for\z/
detect_url_helper($1, *args)
elsif method =~ /(_url|_path)\z/
main_app.send(method, *args)
else
super
end
end
|
Instance Method Details
#detect_url_helper(feature, nyauth_client_name, *args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/helpers/nyauth/application_helper.rb', line 14
def detect_url_helper(feature, nyauth_client_name, *args)
@__methods ||= Nyauth::Engine.routes.url_helpers.instance_methods + Rails.application.routes.url_helpers.instance_methods
@__candidates ||= @__methods.reject{|m| m =~ /\A(:?rails_|_)/}.map(&:to_s)
if respond_to?(:nyauth) && nyauth_client_name.to_sym == :user
detect_url_helper_for_nyauth(feature, *args)
else
detect_url_helper_for_app(feature, nyauth_client_name, *args)
end
end
|
#detect_url_helper_for_app(feature, nyauth_client_name, *args) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/helpers/nyauth/application_helper.rb', line 33
def detect_url_helper_for_app(feature, nyauth_client_name, *args)
if feature =~ /new_(.+)/
path = @__candidates.grep(/\Anew_#{nyauth_client_name}_#{$1}_path\z/).first
else
path = @__candidates.grep(/\A#{nyauth_client_name}_#{feature}_path\z/).first
end
return '' unless path
main_app.__send__(path, *args)
end
|
#detect_url_helper_for_nyauth(feature, *args) ⇒ Object
26
27
28
29
30
31
|
# File 'app/helpers/nyauth/application_helper.rb', line 26
def detect_url_helper_for_nyauth(feature, *args)
path = @__candidates.grep(/\A#{feature}_path\z/).first
return '' unless path
nyauth.__send__(path, *args)
end
|
#root_path ⇒ Object
45
46
47
48
49
50
51
|
# File 'app/helpers/nyauth/application_helper.rb', line 45
def root_path
if main_app.respond_to?(:root_path)
main_app.__send__(:root_path)
else
'/'
end
end
|