Class: Protoplasm::BlockingClient

Inherits:
Object
  • Object
show all
Defined in:
lib/protoplasm/client/blocking_client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.client(*args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/protoplasm/client/blocking_client.rb', line 17

def self.client(*args)
  client = new(*args)
  begin
    yield client
  ensure
    client.close
  end
end

.for_types(types) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/protoplasm/client/blocking_client.rb', line 5

def self.for_types(types)
  cls = Class.new(self)
  cls.class_eval do
    (class << self; self; end).send(:define_method, :_types) { types }
  end
  cls
end

Instance Method Details

#closeObject



13
14
15
# File 'lib/protoplasm/client/blocking_client.rb', line 13

def close
  _socket.close if _socket && !_socket.closed?
end