Class: Clickwrap::ApplicationController
- Inherits:
-
Object
- Object
- Clickwrap::ApplicationController
- Defined in:
- app/controllers/clickwrap/application_controller.rb
Overview
Base controller for every engine screen. It inherits from the HOST's
controller (config.parent_controller_class_name, "::ApplicationController"
by default) so the host's layout, helpers, authentication filters, locale
switching, and exception handling all apply to these screens for free — the
same integration style as the sessions, chats, and api_keys gems.
NOTE: the superclass is resolved when this class is AUTOLOADED, which in a
booted app happens after initializers have run — so a
config.parent_controller_class_name set in
config/initializers/clickwrap.rb is honored. In development the class
reloads on change and picks up configuration changes with it.
Direct Known Subclasses
CapturesController, DocumentVersionsController, ReceiptsController, WithdrawalsController
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object (private)
The host's authentication filters run INSIDE these engine controllers —
that is the entire point of inheriting from the host's parent controller —
and those filters reference the HOST's own route helpers
(new_session_path in the Rails authentication generator, custom
redirects in hand-rolled filters), which an isolated engine's route set
cannot resolve. Delegating unknown *_path/*_url calls to main_app
lets the host's code work in here unmodified. It is the standard engine
idiom, and the alternative is asking every host to special-case its own
authentication for these four screens.
35 36 37 38 39 40 41 |
# File 'app/controllers/clickwrap/application_controller.rb', line 35 def method_missing(method, *, &) if method.to_s.end_with?("_path", "_url") && main_app.respond_to?(method) main_app.public_send(method, *, &) else super end end |