Class: RailsBestPractices::Reviews::SimplifyRenderInViewsReview
- Inherits:
-
Review
- Object
- Core::Check
- Review
- RailsBestPractices::Reviews::SimplifyRenderInViewsReview
- Defined in:
- lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
Overview
Review a view file to make sure using simplified syntax for render.
See the best practice details here rails-bestpractices.com/posts/61-simplify-render-in-views.
Implementation:
Review process:
check all render method calls in view files,
if there is a key 'partial' in the argument, then they should be replaced by simplified syntax.
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_call(call_node) ⇒ Object
check call node in view file, if its message is render and the arguments contain a key partial, then it should be replaced by simplified syntax.
- #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/simplify_render_in_views_review.rb', line 24 def interesting_files VIEW_FILES end |
#interesting_nodes ⇒ Object
20 21 22 |
# File 'lib/rails_best_practices/reviews/simplify_render_in_views_review.rb', line 20 def interesting_nodes [:call] end |
#start_call(call_node) ⇒ Object
check call node in view file, if its message is render and the arguments contain a key partial, then it should be replaced by simplified syntax.
31 32 33 34 35 |
# File 'lib/rails_best_practices/reviews/simplify_render_in_views_review.rb', line 31 def start_call(call_node) if :render == call_node. && call_node.arguments[1].to_s =~ /"partial" =>/ add_error 'simplify render in views' end end |
#url ⇒ Object
16 17 18 |
# File 'lib/rails_best_practices/reviews/simplify_render_in_views_review.rb', line 16 def url "http://rails-bestpractices.com/posts/61-simplify-render-in-views" end |