Class: Routing::ShowRoutes
- Inherits:
-
Object
- Object
- Routing::ShowRoutes
- Defined in:
- lib/routing/show_routes.rb
Constant Summary collapse
- SEGMENT_DIVIDER =
'/'.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.
20 21 22 23 |
# File 'lib/routing/show_routes.rb', line 20 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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/routing/show_routes.rb', line 47 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, 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, WebSvr::WebMethod::POST ] elsif obj.name.eql? ResourceRouter::UPDATE @found_routes << [ '', '', route_path, WebSvr::WebMethod::PATCH ] elsif obj.name.eql? ResourceRouter::DELETE @found_routes << [ '', '', route_path, WebSvr::WebMethod::DELETE ] end end end end |
#headers ⇒ Object
Get the table headers.
85 86 87 |
# File 'lib/routing/show_routes.rb', line 85 def headers return [ 'Obj Name', 'Obj Path', 'Route', 'Method' ] end |
#show(page_container) ⇒ Object
Show all available routes.
33 34 35 36 37 38 39 40 41 |
# File 'lib/routing/show_routes.rb', line 33 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 |
#show_table ⇒ Object
Show the Routes title.
75 76 77 78 79 80 |
# File 'lib/routing/show_routes.rb', line 75 def show_table puts Gloo::App::Platform::RETURN title = "Routes in Running Web App" @engine.platform.table.show headers, @found_routes, title puts Gloo::App::Platform::RETURN end |