Sha256: c33e8c91000d04fbf7ac6955f027c7d76bb7a6ad2c5b9a8d85b2aff1f9b71607

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8
require 'rails_best_practices/reviews/review'

module RailsBestPractices
  module Reviews
    # Review a view file to make sure using simplified syntax for render.
    #
    # See the best practice details here http://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.
    class SimplifyRenderInViewsReview < Review
      def url
        "http://rails-bestpractices.com/posts/61-simplify-render-in-views"
      end

      def interesting_nodes
        [:call]
      end

      def interesting_files
        VIEW_FILES
      end

      # 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.
      def start_call(call_node)
        if :render == call_node.message && call_node.arguments[1].to_s =~ /"partial" =>/
          add_error 'simplify render in views'
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rails_best_practices-0.10.1 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
rails_best_practices-0.10.0 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
rails_best_practices-raydog153-0.9.1 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
rails_best_practices-0.9.0 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
rails_best_practices-0.8.2 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
rails_best_practices-0.8.1 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb
rails_best_practices-0.8.0 lib/rails_best_practices/reviews/simplify_render_in_views_review.rb