Module: LightIO::Wrap::Wrapper::ClassMethods

Includes:
SingletonClassCommonMethods
Included in:
IOWrapper::ClassMethods
Defined in:
lib/lightio/wrap.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (protected)



59
60
61
# File 'lib/lightio/wrap.rb', line 59

def method_missing(method, *args)
  raw_class.public_send(method, *args)
end

Instance Method Details

#_wrap(io) ⇒ Object

Wrap raw io objects



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lightio/wrap.rb', line 29

def _wrap(io)
  # In case ruby stdlib return already patched Sockets, just do nothing
  if io.is_a? self
    io
  else
    # old new
    obj = allocate
    obj.send(:initialize, io)
    obj
  end
end

#new(*args) ⇒ Object

override new method, return wrapped class



42
43
44
45
# File 'lib/lightio/wrap.rb', line 42

def new(*args)
  io = raw_class.new(*args)
  _wrap(io)
end