Class: Decidim::EngineRouter
- Inherits:
-
Object
- Object
- Decidim::EngineRouter
- Defined in:
- lib/decidim/engine_router.rb
Overview
This class is responsible for sending route helper methods to the correct mounted engine. To do that, it needs to know the name of the mounted helper for the engine, and the contextual parameters to identify the mount point for it, which are added to the parameters passed to the route helper.
Instance Attribute Summary collapse
-
#default_url_options ⇒ Object
readonly
Returns the value of attribute default_url_options.
Class Method Summary collapse
-
.admin_proxy(target) ⇒ EngineRouter
Instantiates a router to the backend engine for an object.
-
.main_proxy(target) ⇒ EngineRouter
Instantiates a router to the frontend engine for an object.
Instance Method Summary collapse
-
#initialize(engine, default_url_options) ⇒ EngineRouter
constructor
A new instance of EngineRouter.
- #method_missing(method_name, *args) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(engine, default_url_options) ⇒ EngineRouter
Returns a new instance of EngineRouter.
33 34 35 36 |
# File 'lib/decidim/engine_router.rb', line 33 def initialize(engine, ) @engine = engine @default_url_options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
42 43 44 45 46 |
# File 'lib/decidim/engine_router.rb', line 42 def method_missing(method_name, *args) return super unless route_helper?(method_name) send(@engine).send(method_name, *args) end |
Instance Attribute Details
#default_url_options ⇒ Object (readonly)
Returns the value of attribute default_url_options.
31 32 33 |
# File 'lib/decidim/engine_router.rb', line 31 def @default_url_options end |
Class Method Details
.admin_proxy(target) ⇒ EngineRouter
Instantiates a router to the backend engine for an object.
27 28 29 |
# File 'lib/decidim/engine_router.rb', line 27 def self.admin_proxy(target) new(target.mounted_admin_engine, target.mounted_params) end |
.main_proxy(target) ⇒ EngineRouter
Instantiates a router to the frontend engine for an object.
18 19 20 |
# File 'lib/decidim/engine_router.rb', line 18 def self.main_proxy(target) new(target.mounted_engine, target.mounted_params) end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
38 39 40 |
# File 'lib/decidim/engine_router.rb', line 38 def respond_to_missing?(method_name, include_private = false) route_helper?(method_name) || super end |