Class: Charyf::Engine::Routing::Default
- Defined in:
- lib/charyf/engine/routing/default.rb
Defined Under Namespace
Classes: InvalidRoute
Instance Method Summary collapse
- #draw(&block) ⇒ Object
-
#initialize ⇒ Default
constructor
A new instance of Default.
-
#process(context) ⇒ Object
Context -> Controller.
- #route(intent, to: nil) ⇒ Object
Methods inherited from Base
Methods included from Strategy::BaseClass
Constructor Details
Instance Method Details
#draw(&block) ⇒ Object
18 19 20 |
# File 'lib/charyf/engine/routing/default.rb', line 18 def draw(&block) instance_eval &block end |
#process(context) ⇒ Object
Context -> Controller
23 24 25 |
# File 'lib/charyf/engine/routing/default.rb', line 23 def process(context) @routes[context.intent.name.downcase] || invalid end |
#route(intent, to: nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/charyf/engine/routing/default.rb', line 27 def route(intent, to: nil) raise InvalidRoute.new("route '#{intent}' missing to definition") if to.nil? @routes[intent.downcase] = parse_target(to) end |