Ejemplo n.º 1
0
        private static void ProcessRubyRoutes(IRubyEngine engine, IPathProvider vpp, string routesPath)
        {
            if (!vpp.FileExists(routesPath))
            {
                return;
            }
            var routeCollection = new RubyRoutes(RouteTable.Routes);

            engine.DefineReadOnlyGlobalVariable("routes", routeCollection);
            engine.RequireRubyFile(routesPath, ReaderType.File);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the controller.
        /// </summary>
        /// <param name="requestContext">The request context.</param>
        /// <param name="controllerName">Name of the controller.</param>
        /// <returns></returns>
        private RubyController LoadController(RequestContext requestContext, string controllerName)
        {
            var controllerFilePath  = GetControllerFilePath(controllerName);
            var controllerClassName = GetControllerClassName(controllerName);

            _engine.RemoveClassFromGlobals(controllerClassName);

            if (controllerFilePath.IsNullOrBlank())
            {
                return(null);
            }

            _engine.RequireRubyFile(controllerFilePath, ReaderType.File);

            var controllerClass = _engine.GetRubyClass(controllerClassName);
            var controller      = ConfigureController(controllerClass, requestContext);

            return(controller);
        }