Module: Zoidberg::Shell::ClassMethods
- Defined in:
- lib/zoidberg/shell.rb
Instance Method Summary collapse
-
#new(*args, &block) ⇒ Object
Override real instance’s .new method to provide a proxy instance.
-
#trap_exit(m_name = nil) ⇒ String, Symbol
Trap unhandled exceptions from linked instances and handle via given method name.
Instance Method Details
#new(*args, &block) ⇒ Object
Override real instance’s .new method to provide a proxy instance
307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/zoidberg/shell.rb', line 307 def new(*args, &block) if(self.include?(Zoidberg::HardShell)) proxy = Zoidberg::Proxy::Confined.new(self, *args, &block) elsif(self.include?(Zoidberg::SoftShell)) proxy = Zoidberg::Proxy::Liberated.new(self, *args, &block) else raise TypeError.new "Unable to determine `Shell` type for this class `#{self}`!" end proxy._zoidberg_set_instance(self.unshelled_new(*args, &block)) weak_ref = Zoidberg::WeakRef.new(proxy) Zoidberg::Proxy.register(weak_ref.__id__, proxy) ObjectSpace.define_finalizer(weak_ref, Zoidberg::Proxy.method(:scrub!)) weak_ref end |
#trap_exit(m_name = nil) ⇒ String, Symbol
Trap unhandled exceptions from linked instances and handle via given method name
327 328 329 330 331 332 |
# File 'lib/zoidberg/shell.rb', line 327 def trap_exit(m_name=nil) if(m_name) @m_name = m_name end @m_name end |