class RailsBestPractices::Reviews::SimplifyRenderInViewsReview
Review
a view file to make sure using simplified syntax for render.
See the best practice details here rails-bestpractices.com/posts/2010/12/04/simplify-render-in-views/
Implementation:
Review
process:
check all render method commands in view files, if there is a key 'partial' in the argument, then they should be replaced by simplified syntax.
Constants
- VALID_KEYS
Protected Instance Methods
include_partial?(hash_node)
click to toggle source
# File lib/rails_best_practices/reviews/simplify_render_in_views_review.rb, line 36 def include_partial?(hash_node) hash_node.hash_keys.include?('partial') && !hash_node.hash_value('partial').to_s.include?('/') end
valid_hash?(hash_node)
click to toggle source
# File lib/rails_best_practices/reviews/simplify_render_in_views_review.rb, line 40 def valid_hash?(hash_node) keys = hash_node.hash_keys keys.delete('partial') (keys - VALID_KEYS).empty? end