Class: ActionDispatch::Routing::RoutesProxy
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::RoutesProxy
- Includes:
- UrlFor
- Defined in:
- lib/action_dispatch/routing/routes_proxy.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#routes ⇒ Object
(also: #_routes)
Returns the value of attribute routes.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(routes, scope, helpers) ⇒ RoutesProxy
constructor
A new instance of RoutesProxy.
- #method_missing(method, *args) ⇒ Object
- #respond_to?(method, include_private = false) ⇒ Boolean
- #url_options ⇒ Object
Methods included from UrlFor
Methods included from PolymorphicRoutes
#polymorphic_path, #polymorphic_url
Methods included from ActionController::ModelNaming
#convert_to_model, #model_name_from_record_or_class
Constructor Details
#initialize(routes, scope, helpers) ⇒ RoutesProxy
Returns a new instance of RoutesProxy.
11 12 13 14 |
# File 'lib/action_dispatch/routing/routes_proxy.rb', line 11 def initialize(routes, scope, helpers) @routes, @scope = routes, scope @helpers = helpers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/action_dispatch/routing/routes_proxy.rb', line 26 def method_missing(method, *args) if @helpers.respond_to?(method) self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{method}(*args) options = args.extract_options! args << url_options.merge((options || {}).symbolize_keys) @helpers.#{method}(*args) end RUBY send(method, *args) else super end end |
Instance Attribute Details
#routes ⇒ Object Also known as: _routes
Returns the value of attribute routes.
8 9 10 |
# File 'lib/action_dispatch/routing/routes_proxy.rb', line 8 def routes @routes end |
#scope ⇒ Object
Returns the value of attribute scope.
8 9 10 |
# File 'lib/action_dispatch/routing/routes_proxy.rb', line 8 def scope @scope end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
22 23 24 |
# File 'lib/action_dispatch/routing/routes_proxy.rb', line 22 def respond_to?(method, include_private = false) super || @helpers.respond_to?(method) end |
#url_options ⇒ Object
16 17 18 19 20 |
# File 'lib/action_dispatch/routing/routes_proxy.rb', line 16 def scope.send(:_with_routes, routes) do scope. end end |