module RailsBestPractices::Core::Check::Exceptable
Helper to check except methods.
Public Class Methods
included(base)
click to toggle source
# File lib/rails_best_practices/core/check.rb, line 358 def self.included(base) base.class_eval do def except_methods @except_methods + internal_except_methods end # check if the method is in the except methods list. def excepted?(method) is_ignored?(method.file) || except_methods.any? { |except_method| Exceptable.matches method, except_method } end def internal_except_methods raise NoMethodError, 'no method internal_except_methods' end end end
matches(method, except_method)
click to toggle source
# File lib/rails_best_practices/core/check.rb, line 376 def self.matches(method, except_method) class_name, method_name = except_method.split('#') method_name = '.*' if method_name == '*' method_expression = Regexp.new method_name matched = method.method_name =~ method_expression if matched class_name = '.*' if class_name == '*' class_expression = Regexp.new class_name class_names = Prepares.klasses.select { |klass| klass.class_name == method.class_name }.map(&:extend_class_name).compact class_names.unshift method.class_name matched = class_names.any? { |name| name =~ class_expression } end !!matched end
Public Instance Methods
except_methods()
click to toggle source
# File lib/rails_best_practices/core/check.rb, line 360 def except_methods @except_methods + internal_except_methods end
excepted?(method)
click to toggle source
check if the method is in the except methods list.
# File lib/rails_best_practices/core/check.rb, line 365 def excepted?(method) is_ignored?(method.file) || except_methods.any? { |except_method| Exceptable.matches method, except_method } end
internal_except_methods()
click to toggle source
# File lib/rails_best_practices/core/check.rb, line 370 def internal_except_methods raise NoMethodError, 'no method internal_except_methods' end