Class: NilClass

Inherits:
Object show all
Defined in:
lib/i_dont_give_a_shit.rb

Overview

Open up Nil to add handling of ?.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Catches all calls that were put on nil references ending with ? returning nil again. Calls without a question-mark are send to original method_missing.



27
28
29
30
31
32
33
34
35
36
# File 'lib/i_dont_give_a_shit.rb', line 27

def method_missing(sym,*args, &block)
  method_name = sym.to_s
  if /.+\?$/ =~ method_name
    puts "nil '#{sym}' '#{args}' '#{block}'"
    self
  else
    puts "nil missing '#{sym}' '#{args}' '#{block}'"
    super.m_m(sym,*args, &block)
  end
end