Class: Excursion::Helpers::UrlHelper
- Inherits:
-
Object
- Object
- Excursion::Helpers::UrlHelper
show all
- Defined in:
- lib/excursion/helpers/url_helper.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/excursion/helpers/url_helper.rb', line 10
def method_missing(meth, *args)
if meth.to_s.match(/\A(#{routes.collect { |name,route| name }.join("|")})_(url|path)\Z/)
route = routes.get($1.to_sym)
url_opts = @application.default_url_options.clone
url_opts.merge!(args.slice!(args.length-1)) if args.last.is_a?(Hash)
return ActionDispatch::Http::URL.url_for(url_opts.merge({path: replaced_path(route, args)}))
else
super
end
end
|
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
4
5
6
|
# File 'lib/excursion/helpers/url_helper.rb', line 4
def application
@application
end
|
Instance Method Details
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
34
35
36
|
# File 'lib/excursion/helpers/url_helper.rb', line 34
def respond_to_missing?(meth, include_private=false)
meth.to_s.match(/\A(#{routes.collect { |name,route| name }.join("|")})_(url|path)\Z/) || super
end
|
#routes ⇒ Object
6
7
8
|
# File 'lib/excursion/helpers/url_helper.rb', line 6
def routes
@application.routes
end
|