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
|
# File 'lib/excursion/helpers/url_helper.rb', line 10
def method_missing(meth, *args)
route = @application.route(route_name_from_method(meth))
if route.nil?
super
else
if meth.to_s.match(/_url\Z/)
url_opts = (@application.default_url_options || {}).clone
url_opts.merge!(args.slice!(args.length-1)) if args.last.is_a?(Hash)
ActionDispatch::Http::URL.url_for(url_opts.merge({path: replaced_path(route, args)}))
elsif meth.to_s.match(/_path\Z/)
replaced_path(route, args)
end
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
26
27
28
|
# File 'lib/excursion/helpers/url_helper.rb', line 26
def respond_to_missing?(meth, include_private=false)
!@application.route(route_name_from_method(meth)).nil? || super
end
|
#routes ⇒ Object
6
7
8
|
# File 'lib/excursion/helpers/url_helper.rb', line 6
def routes
@application.routes
end
|