-
Notifications
You must be signed in to change notification settings - Fork 133
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 NameError da página Active Support… #801
Open
rohan-techfreak
wants to merge
1
commit into
campuscode:main
Choose a base branch
from
rohan-techfreak:topic-800
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4008,13 +4008,13 @@ NOTE: Defined in `active_support/core_ext/file/atomic.rb`. | |||||
Extensions to `NameError` | ||||||
------------------------- | ||||||
|
||||||
Active Support adds [`missing_name?`][NameError#missing_name?] to `NameError`, which tests whether the exception was raised because of the name passed as argument. | ||||||
Suporte ativo adiciona [`missing_name?`][NameError#missing_name?] para `NameError`, que testa se a exceção foi levantada por causa do nome passado como argumento. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
The name may be given as a symbol or string. A symbol is tested against the bare constant name, a string is against the fully qualified constant name. | ||||||
O nome pode ser dado como um símbolo ou string. Um símbolo é testado em relação ao nome da constante simples, uma string é testada em relação ao nome da constante totalmente qualificado. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
TIP: A symbol can represent a fully qualified constant name as in `:"ActiveRecord::Base"`, so the behavior for symbols is defined for convenience, not because it has to be that way technically. | ||||||
TIP: Um símbolo pode representar um nome de constante totalmente qualificado como em `:"ActiveRecord::Base"`, então o comportamento dos símbolos é definido por conveniência, não porque tem que ser assim tecnicamente. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
For example, when an action of `ArticlesController` is called Rails tries optimistically to use `ArticlesHelper`. It is OK that the helper module does not exist, so if an exception for that constant name is raised it should be silenced. But it could be the case that `articles_helper.rb` raises a `NameError` due to an actual unknown constant. That should be reraised. The method `missing_name?` provides a way to distinguish both cases: | ||||||
Por exemplo, quando uma ação de `ArticlesController` é chamado Rails tenta usar com otimismo `ArticlesHelper`. Não há problema em que o módulo auxiliar não exista, portanto, se uma exceção para esse nome constante for levantada, ela deve ser silenciada. Mas pode ser que `articles_helper.rb` levanta um `NameError` devido a uma constante real desconhecida. Isso deve ser refeito. O método `missing_name?` fornece uma maneira de distinguir os dois casos: | ||||||
|
||||||
```ruby | ||||||
def default_helper_module! | ||||||
|
@@ -4028,7 +4028,7 @@ rescue NameError => e | |||||
end | ||||||
``` | ||||||
|
||||||
NOTE: Defined in `active_support/core_ext/name_error.rb`. | ||||||
NOTE: Definido em `active_support/core_ext/name_error.rb`. | ||||||
|
||||||
[NameError#missing_name?]: https://api.rubyonrails.org/classes/NameError.html#method-i-missing_name-3F | ||||||
|
||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.