Skip to content
  • Daniel Colson's avatar
    754ed1f4
    Restore the behavior of journey root node methods · 754ed1f4
    Daniel Colson authored
    https://github.com/rails/rails/pull/39935 changed the behavior of
    `Path::Pattern#spec` and `Route#ast` to return an `Ast` rather than the
    root `Node`. After eager loading, however, we clear out the `Ast` to
    limit retained memory and these methods return `nil`.
    
    While these methods are not public and they aren't used internally after
    eager loading, having them return `nil` makes it difficult for
    applications that had been using these methods to get access to the
    root `Node`.
    
    This commit restores the behavior of these two methods to return the
    root `Node`. The `Ast` is still available via `Path::Pattern#ast`, and
    we still clear it out after eager loading.
    
    Now that spec is a `Node` and not an `Ast` masquerading as one, we can
    get rid of the delegate methods on `Ast.
    
    Since `Route#ast` now returns the root `Node`, the newly added
    `Route#ast_root` is no longer necessary so I've removed it.
    
    I also removed the unused `@decorated_ast` method, which should have
    been removed in https://github.com/rails/rails/pull/39935.
    754ed1f4
    Restore the behavior of journey root node methods
    Daniel Colson authored
    https://github.com/rails/rails/pull/39935 changed the behavior of
    `Path::Pattern#spec` and `Route#ast` to return an `Ast` rather than the
    root `Node`. After eager loading, however, we clear out the `Ast` to
    limit retained memory and these methods return `nil`.
    
    While these methods are not public and they aren't used internally after
    eager loading, having them return `nil` makes it difficult for
    applications that had been using these methods to get access to the
    root `Node`.
    
    This commit restores the behavior of these two methods to return the
    root `Node`. The `Ast` is still available via `Path::Pattern#ast`, and
    we still clear it out after eager loading.
    
    Now that spec is a `Node` and not an `Ast` masquerading as one, we can
    get rid of the delegate methods on `Ast.
    
    Since `Route#ast` now returns the root `Node`, the newly added
    `Route#ast_root` is no longer necessary so I've removed it.
    
    I also removed the unused `@decorated_ast` method, which should have
    been removed in https://github.com/rails/rails/pull/39935.
Loading