Class: FilterDecrufter::Report
- Inherits:
-
Object
- Object
- FilterDecrufter::Report
- Defined in:
- lib/filter_decrufter/checker.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
Returns the value of attribute hits.
Class Method Summary collapse
Instance Method Summary collapse
- #add(hit) ⇒ Object
- #check_constraint(name, hit) ⇒ Object
- #find_problems ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
38 39 40 |
# File 'lib/filter_decrufter/checker.rb', line 38 def initialize @hits = [] end |
Instance Attribute Details
#hits ⇒ Object
Returns the value of attribute hits.
32 33 34 |
# File 'lib/filter_decrufter/checker.rb', line 32 def hits @hits end |
Class Method Details
Instance Method Details
#add(hit) ⇒ Object
42 43 44 45 |
# File 'lib/filter_decrufter/checker.rb', line 42 def add(hit) raise "Oops filter_decrufter can't handle this version of Rails" unless hit.controller_class.respond_to?(:action_methods) hits << hit end |
#check_constraint(name, hit) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/filter_decrufter/checker.rb', line 57 def check_constraint(name, hit) [hit.[name]].flatten.each do |action_syms| [action_syms].flatten.each do |action_name| if !hit.actions_include?(action_name) puts "#{hit.controller_class} #{hit.filter_type} '#{hit.filter_name}' has an :#{name} constraint with a non-existent action name '#{action_name}'" end end end end |
#find_problems ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/filter_decrufter/checker.rb', line 47 def find_problems hits.each do |hit| hit..each do |k,v| [:only, :except].each do |constraint_name| check_constraint(constraint_name, hit) if hit.[constraint_name].present? end end end end |