Class: RailsBestPractices::Reviews::ReplaceInstanceVariableWithLocalVariableReview
- Inherits:
-
Review
- Object
- Core::Check
- Review
- RailsBestPractices::Reviews::ReplaceInstanceVariableWithLocalVariableReview
- Defined in:
- lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb
Overview
Review a partail view file to make sure there is no instance variable.
See the best practice details here rails-bestpractices.com/posts/27-replace-instance-variable-with-local-variable.
Implementation:
Review process:
check all instance variable in partial view files,
if exist, then they should be replaced with local variable
Constant Summary
Constants inherited from Core::Check
Core::Check::CONTROLLER_FILES, Core::Check::HELPER_FILES, Core::Check::MAILER_FILES, Core::Check::MIGRATION_FILES, Core::Check::MODEL_FILES, Core::Check::NODE_TYPES, Core::Check::PARTIAL_VIEW_FILES, Core::Check::ROUTE_FILE, Core::Check::SCHEMA_FILE, Core::Check::VIEW_FILES
Instance Attribute Summary
Attributes inherited from Core::Check
Instance Method Summary collapse
- #interesting_files ⇒ Object
- #interesting_nodes ⇒ Object
-
#start_ivar(node) ⇒ Object
check ivar node in partial view file, it is an instance variable, and should be replaced with local variable.
- #url ⇒ Object
Methods inherited from Review
#equal?, #model_associations, #model_attributes, #models, #remember_variable_use_count, #reset_variable_use_count, #variable, #variable_use_count
Methods inherited from Core::Check
#add_error, #initialize, #method_missing, #node_end, #node_start
Constructor Details
This class inherits a constructor from RailsBestPractices::Core::Check
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RailsBestPractices::Core::Check
Instance Method Details
#interesting_files ⇒ Object
24 25 26 |
# File 'lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb', line 24 def interesting_files PARTIAL_VIEW_FILES end |
#interesting_nodes ⇒ Object
20 21 22 |
# File 'lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb', line 20 def interesting_nodes [:ivar] end |
#start_ivar(node) ⇒ Object
check ivar node in partial view file, it is an instance variable, and should be replaced with local variable.
30 31 32 |
# File 'lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb', line 30 def start_ivar(node) add_error "replace instance variable with local variable" end |
#url ⇒ Object
16 17 18 |
# File 'lib/rails_best_practices/reviews/replace_instance_variable_with_local_variable_review.rb', line 16 def url "http://rails-bestpractices.com/posts/27-replace-instance-variable-with-local-variable" end |