Class: Excursion::Builders::UrlBuilder
- Inherits:
-
Object
- Object
- Excursion::Builders::UrlBuilder
show all
- Defined in:
- lib/excursion/builders/url_builder.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/excursion/builders/url_builder.rb', line 13
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 Method Details
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
29
30
31
|
# File 'lib/excursion/builders/url_builder.rb', line 29
def respond_to_missing?(meth, include_private=false)
!application.route(route_name_from_method(meth)).nil? || super
end
|
#routes ⇒ Object
9
10
11
|
# File 'lib/excursion/builders/url_builder.rb', line 9
def routes
application.routes
end
|