Class: INatGet::App::Server::Proxy
- Inherits:
-
Object
- Object
- INatGet::App::Server::Proxy
show all
- Defined in:
- lib/inat-get/app/core/server.rb
Instance Method Summary
collapse
Constructor Details
#initialize(detacher, socket_path, wait_answer = true) ⇒ Proxy
Returns a new instance of Proxy.
75
76
77
78
79
|
# File 'lib/inat-get/app/core/server.rb', line 75
def initialize detacher, socket_path, wait_answer = true
@detacher = detacher
@socket_path = socket_path
@wait_answer = wait_answer
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, **kwargs) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/inat-get/app/core/server.rb', line 94
def method_missing sym, *args, **kwargs
kwargs[:_sender_pid] = ::Process::pid
msg = {
method: sym,
args: args,
kwargs: kwargs
}
socket = ::UNIXSocket::new @socket_path
::Marshal.dump msg, socket
result = @wait_answer ? ::Marshal.load(socket) : true
socket.close
result
rescue => e
pp e
false
end
|
Instance Method Details
#alive? ⇒ Boolean
90
91
92
|
# File 'lib/inat-get/app/core/server.rb', line 90
def alive?
@detacher.alive?
end
|
#close ⇒ Object
81
82
83
84
|
# File 'lib/inat-get/app/core/server.rb', line 81
def close
self.quit
@detacher.join
end
|
#pid ⇒ Object
86
87
88
|
# File 'lib/inat-get/app/core/server.rb', line 86
def pid
@detacher.pid
end
|