Class: NYNY::Router
- Inherits:
-
Object
- Object
- NYNY::Router
- Defined in:
- lib/nyny/router.rb
Instance Attribute Summary collapse
-
#after_hooks ⇒ Object
readonly
Returns the value of attribute after_hooks.
-
#before_hooks ⇒ Object
readonly
Returns the value of attribute before_hooks.
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
-
#journey ⇒ Object
readonly
Returns the value of attribute journey.
-
#scope_class ⇒ Object
readonly
Returns the value of attribute scope_class.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(options) ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize(options) ⇒ Router
Returns a new instance of Router.
8 9 10 11 12 13 14 15 |
# File 'lib/nyny/router.rb', line 8 def initialize @scope_class = [:scope_class] @before_hooks = [:before_hooks] @after_hooks = [:after_hooks] @fallback = [:fallback] prepare_for_journey([:route_defs]) end |
Instance Attribute Details
#after_hooks ⇒ Object (readonly)
Returns the value of attribute after_hooks.
7 8 9 |
# File 'lib/nyny/router.rb', line 7 def after_hooks @after_hooks end |
#before_hooks ⇒ Object (readonly)
Returns the value of attribute before_hooks.
7 8 9 |
# File 'lib/nyny/router.rb', line 7 def before_hooks @before_hooks end |
#fallback ⇒ Object (readonly)
Returns the value of attribute fallback.
7 8 9 |
# File 'lib/nyny/router.rb', line 7 def fallback @fallback end |
#journey ⇒ Object (readonly)
Returns the value of attribute journey.
7 8 9 |
# File 'lib/nyny/router.rb', line 7 def journey @journey end |
#scope_class ⇒ Object (readonly)
Returns the value of attribute scope_class.
7 8 9 |
# File 'lib/nyny/router.rb', line 7 def scope_class @scope_class end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/nyny/router.rb', line 17 def call env response = journey.call(env) if response[0] == 404 and fallback fallback.call(env) else response end end |