Class: NilClass

Inherits:
Object
  • Object
show all
Defined in:
lib/NilBeGone.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/NilBeGone.rb', line 5

def method_missing(method, *args, &block)
  missing_value = nil
  n = 2
  loop do
    begin
      missing_value = binding.of_caller(n).eval('nil_value rescue nil')
      return missing_value.send(method, *args, &block) unless missing_value.nil?
      n += 1
    rescue
      break
    end
  end
  super
end