abstract class
UI::Controller
- UI::Controller
- Reference
- Object
Overview
Abstract base class for native-target controllers that turn user actions into ActionResult values.
Defined in:
asset_pipeline/native_app.crasset_pipeline/native_controller.cr
Class Method Summary
-
._before_actions : Array(Proc(UI::Controller, UI::ScreenContext::Native, UI::ActionResult | Nil))
Abstract default — no callbacks registered.
Macro Summary
-
before_action(method_name)
Register a before_action.
Instance Method Summary
-
#dispatch_action(name : Symbol, context : UI::ScreenContext::Native) : UI::ActionResult
Subclasses override this method with a
casedispatch over the action names they implement.
Class Method Detail
Abstract default — no callbacks registered.
Macro Detail
Register a before_action. The method must accept a
UI::ScreenContext::Native and return UI::ActionResult?.
before_action :require_authenticated
private def require_authenticated(context)
return nil if context.session["user_email"]?
navigate_to(:sign_in)
end
Implementation: emits a compile-time class method
_before_action_<method_name>_proc that builds and returns the
callback proc on demand. ._before_actions enumerates those
methods to assemble the list. Compile-time method emission is
gap-safe; the prior @@_before_actions << ... class-body side
effect was not.
Instance Method Detail
Subclasses override this method with a case dispatch over the
action names they implement. The default implementation raises
UnknownActionError with guidance pointing the author at the
override path.