Class: Gloo::WebSvr::Routing::ShowRoutes
- Inherits:
-
Object
- Object
- Gloo::WebSvr::Routing::ShowRoutes
- Defined in:
- lib/gloo/web_svr/routing/show_routes.rb
Constant Summary collapse
- SEGMENT_DIVIDER =
'/'.freeze
- RETURN =
"\n".freeze
Instance Method Summary collapse
-
#add_container_routes(can, route_path) ⇒ Object
Show the routes in the given container.
-
#headers ⇒ Object
Get the table headers.
-
#initialize(engine) ⇒ ShowRoutes
constructor
Set up the web server.
-
#show(page_container) ⇒ Object
Show all available routes.
-
#show_table ⇒ Object
Show the Routes title.
Constructor Details
#initialize(engine) ⇒ ShowRoutes
Set up the web server.
23 24 25 26 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 23 def initialize( engine ) @engine = engine @log = @engine.log end |
Instance Method Details
#add_container_routes(can, route_path) ⇒ Object
Show the routes in the given container. This is a recursive function travese the object tree.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 50 def add_container_routes can, route_path can.children.each do |obj| if obj.class == Gloo::Objs::Container add_container_routes obj, "#{route_path}#{obj.name}#{SEGMENT_DIVIDER}" elsif obj.class == Gloo::Objs::Page route = "#{route_path}#{obj.name}" @found_routes << [ obj.name, obj.pn, route, Gloo::WebSvr::WebMethod::GET ] # If the method is POST, add a route alias for the create. if obj.name.eql? ResourceRouter::POST_ROUTE @found_routes << [ '', '', route_path, Gloo::WebSvr::WebMethod::POST ] elsif obj.name.eql? ResourceRouter::UPDATE @found_routes << [ '', '', route_path, Gloo::WebSvr::WebMethod::PATCH ] elsif obj.name.eql? ResourceRouter::DELETE @found_routes << [ '', '', route_path, Gloo::WebSvr::WebMethod::DELETE ] end end end end |
#headers ⇒ Object
Get the table headers.
88 89 90 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 88 def headers return [ 'Obj Name', 'Obj Path', 'Route', 'Method' ] end |
#show(page_container) ⇒ Object
Show all available routes.
36 37 38 39 40 41 42 43 44 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 36 def show page_container @log.debug "showing routes" @found_routes = [] @log.debug "building route table" add_container_routes( page_container, SEGMENT_DIVIDER ) show_table end |