Class: Plum::Rack::UNIXListener

Inherits:
BaseListener show all
Defined in:
lib/plum/rack/listener.rb

Instance Method Summary collapse

Methods inherited from BaseListener

#method_missing

Constructor Details

#initialize(lc) ⇒ UNIXListener

Returns a new instance of UNIXListener.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/plum/rack/listener.rb', line 98

def initialize(lc)
  if File.exist?(lc[:path])
    begin
      old = UNIXSocket.new(lc[:path])
    rescue SystemCallError, IOError
      File.unlink(lc[:path])
    else
      old.close
      raise "Already a server bound to: #{lc[:path]}"
    end
  end

  @server = ::UNIXServer.new(lc[:path])

  File.chmod(lc[:mode], lc[:path]) if lc[:mode]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plum::Rack::BaseListener

Instance Method Details

#plum(sock) ⇒ Object



124
125
126
# File 'lib/plum/rack/listener.rb', line 124

def plum(sock)
  ::Plum::HTTPSServerConnection.new(sock)
end

#stopObject



115
116
117
118
# File 'lib/plum/rack/listener.rb', line 115

def stop
  super
  File.unlink(lc[:path])
end

#to_ioObject



120
121
122
# File 'lib/plum/rack/listener.rb', line 120

def to_io
  @server.to_io
end