Class: Takagi::CompositeRouter::MountedController
- Inherits:
-
Struct
- Object
- Struct
- Takagi::CompositeRouter::MountedController
- Defined in:
- lib/takagi/composite_router.rb
Overview
Represents a mounted controller with its path and router
Instance Attribute Summary collapse
-
#controller_class ⇒ Object
Returns the value of attribute controller_class.
-
#mount_path ⇒ Object
Returns the value of attribute mount_path.
-
#nested_controllers ⇒ Object
Returns the value of attribute nested_controllers.
-
#router ⇒ Object
Returns the value of attribute router.
Instance Method Summary collapse
-
#handles?(path) ⇒ Boolean
Check if this mount handles the given path.
-
#relative_path(path) ⇒ String
Strip the mount prefix from a path.
Instance Attribute Details
#controller_class ⇒ Object
Returns the value of attribute controller_class
17 18 19 |
# File 'lib/takagi/composite_router.rb', line 17 def controller_class @controller_class end |
#mount_path ⇒ Object
Returns the value of attribute mount_path
17 18 19 |
# File 'lib/takagi/composite_router.rb', line 17 def mount_path @mount_path end |
#nested_controllers ⇒ Object
Returns the value of attribute nested_controllers
17 18 19 |
# File 'lib/takagi/composite_router.rb', line 17 def nested_controllers @nested_controllers end |
#router ⇒ Object
Returns the value of attribute router
17 18 19 |
# File 'lib/takagi/composite_router.rb', line 17 def router @router end |
Instance Method Details
#handles?(path) ⇒ Boolean
Check if this mount handles the given path
22 23 24 |
# File 'lib/takagi/composite_router.rb', line 22 def handles?(path) path.start_with?(mount_path) end |
#relative_path(path) ⇒ String
Strip the mount prefix from a path
30 31 32 33 34 |
# File 'lib/takagi/composite_router.rb', line 30 def relative_path(path) return path if mount_path == '/' path.sub(/^#{Regexp.escape(mount_path)}/, '') || '/' end |