Files

RailsBestPractices::Checks::MoveCodeIntoHelperCheck

Check a view file to make sure there is no complex options_for_select message call.

Implementation: Check if first argument of options_for_select is an array and contains more than two nodes, then it should be moved into helper.

Public Class Methods

new(options = {}) click to toggle source
# File lib/rails_best_practices/checks/move_code_into_helper_check.rb, line 18
def initialize(options = {})
  super()
  @array_count = options['array_count'] || 3
end

Public Instance Methods

evaluate_start(node) click to toggle source
# File lib/rails_best_practices/checks/move_code_into_helper_check.rb, line 23
def evaluate_start(node)
  add_error "move code into helper (array_count >= #{@array_count})" if complex_select_options?(node)
end
interesting_files() click to toggle source
# File lib/rails_best_practices/checks/move_code_into_helper_check.rb, line 14
def interesting_files
  VIEW_FILES
end
interesting_nodes() click to toggle source
# File lib/rails_best_practices/checks/move_code_into_helper_check.rb, line 10
def interesting_nodes
  [:call]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.