Class: Jtor::StdLib::SuperObject
- Inherits:
-
Object
- Object
- Jtor::StdLib::SuperObject
- Defined in:
- lib/jtor-stdlib/superobject.rb
Instance Method Summary collapse
-
#initialize(obj) ⇒ SuperObject
constructor
A new instance of SuperObject.
- #method_missing(symbol, *args, &block) ⇒ Object
Constructor Details
#initialize(obj) ⇒ SuperObject
Returns a new instance of SuperObject.
4 5 6 |
# File 'lib/jtor-stdlib/superobject.rb', line 4 def initialize(obj) @obj = obj end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/jtor-stdlib/superobject.rb', line 8 def method_missing(symbol, *args, &block) superclass = @obj.class.superclass if superclass < Base # If it's a Jtor class superclass.lookup(@obj, symbol, *args) else # All other classes (from http://stackoverflow.com/a/1251199) superclass.instance_method(symbol).bind(@obj).call(*args, &block) end end |