Method: Delorean::Ruby::Whitelists::Base#add_class_method

Defined in:
lib/delorean/ruby/whitelists/base.rb

#add_class_method(method_name, match_to: nil, &block) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/delorean/ruby/whitelists/base.rb', line 32

def add_class_method(method_name, match_to: nil, &block)
  return method_name_error unless method_name.is_a?(Symbol)
  return block_and_match_error if !match_to.nil? && block_given?

  unless match_to.nil?
    return add_class_matched_method(
      method_name: method_name, match_to: match_to
    )
  end

  matcher = class_method_matchers[method_name.to_sym]

  return matcher.extend_matcher(&block) if matcher

  class_method_matchers[method_name.to_sym] = method_matcher_class.new(
    method_name: method_name, &block
  )
end