Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/i_dont_give_a_shit.rb
Overview
Open up Object to add handling of ?.
Instance Method Summary collapse
-
#m_m ⇒ Object
Save a reference to original
method_missing
. -
#method_missing(sym, *args, &block) ⇒ Object
Catches all calls that were intended to go to the real object ending with ?.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
Catches all calls that were intended to go to the real object ending with ?. The question-mark is stripped and the call is processed again. Calls without a question-mark are send to the original method_missing
.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/i_dont_give_a_shit.rb', line 10 def method_missing(sym,*args, &block) method_name = sym.to_s if /.+\?$/ =~ method_name puts "object '#{sym}' '#{args}' '#{block}'" send(method_name[0..-2], *args, &block) else puts "object missing '#{sym}' '#{args}' '#{block}'" m_m(sym,*args, &block) end end |
Instance Method Details
#m_m ⇒ Object
Save a reference to original method_missing
.
5 |
# File 'lib/i_dont_give_a_shit.rb', line 5 alias m_m method_missing |