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
281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/zoidberg/shell.rb', line 281 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 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
300 301 302 303 304 305 |
# File 'lib/zoidberg/shell.rb', line 300 def trap_exit(m_name=nil) if(m_name) @m_name = m_name end @m_name end |