Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradução do tópico - Extensions to LoadError da página Active Support #803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pt-BR/active_support_core_extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4035,11 +4035,11 @@ NOTE: Defined in `active_support/core_ext/name_error.rb`.
Extensions to `LoadError`
-------------------------

Active Support adds [`is_missing?`][LoadError#is_missing?] to `LoadError`.
Suporte ativo adiciona [`is_missing?`][LoadError#is_missing?] para `LoadError`.

Given a path name `is_missing?` tests whether the exception was raised due to that particular file (except perhaps for the ".rb" extension).
Dado um nome de caminho `is_missing?` testa se a exceção foi gerada devido a esse arquivo específico (exceto talvez pelo ".rb" extension).

For example, when an action of `ArticlesController` is called Rails tries to load `articles_helper.rb`, but that file may not exist. That's fine, the helper module is not mandatory so Rails silences a load error. But it could be the case that the helper module does exist and in turn requires another library that is missing. In that case Rails must reraise the exception. The method `is_missing?` provides a way to distinguish both cases:
Por exemplo, quando uma ação de `ArticlesController` é chamado Rails tenta carregar `articles_helper.rb`, mas esse arquivo pode não existir. Tudo bem, o módulo auxiliar não é obrigatório, então o Rails silencia um erro de carregamento. Mas pode ser que o módulo auxiliar exista e, por sua vez, exija outra biblioteca que esteja faltando. Nesse caso, o Rails deve re-aumentar a exceção. O método `is_missing?` fornece uma maneira de distinguir os dois casos:

```ruby
def default_helper_module!
Expand All @@ -4053,7 +4053,7 @@ rescue NameError => e
end
```

NOTE: Defined in `active_support/core_ext/load_error.rb`.
NOTE: Definido em `active_support/core_ext/load_error.rb`.

[LoadError#is_missing?]: https://api.rubyonrails.org/classes/LoadError.html#method-i-is_missing-3F

Expand Down