Class: Excursion::Builders::UrlBuilder

Inherits:
Object
  • Object
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



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/excursion/builders/url_builder.rb', line 17

def method_missing(meth, *args)
  route = application.route(route_name_from_method(meth))
  if route
    if meth.to_s.match(/_url\Z/)
      url_for(route, *args)
    elsif meth.to_s.match(/_path\Z/)
      replaced_path(route, *args)
    end
  else
    super
  end
end

Instance Method Details

#applicationObject



5
6
7
# File 'lib/excursion/builders/url_builder.rb', line 5

def application
  Excursion::Pool.application(@appname)
end

#respond_to_missing?(meth, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/excursion/builders/url_builder.rb', line 30

def respond_to_missing?(meth, include_private=false)
  !application.route(route_name_from_method(meth)).nil? || super
end

#routesObject



9
10
11
# File 'lib/excursion/builders/url_builder.rb', line 9

def routes
  application.routes
end

#url_for(route, *args) ⇒ Object



13
14
15
# File 'lib/excursion/builders/url_builder.rb', line 13

def url_for(route, *args)
  ActionDispatch::Http::URL.url_for(route_options(route, *args))
end