Module: Autocorrect::Insane

Includes:
Common
Defined in:
lib/autocorrect/insane.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/autocorrect/insane.rb', line 7

def method_missing(method, *args, &block)
  # Cargo-culted from whiny_nil.rb
  if method == :to_ary || method == :to_str
    super
  elsif guessed_method = guess_callable_method_for(method, args.length)
    method_missing_warning_for guessed_method, method, args
    send guessed_method, *args, &block
  elsif guessed_method = guess_closest_matched_name_method_for(method)
    raise_method_missing_with_mismatched_args_warning_for guessed_method, method, args, caller
  else
    super
  end
end