Class: Boogaloo::Client::Connection
- Inherits:
-
Object
- Object
- Boogaloo::Client::Connection
- Defined in:
- lib/boogaloo/client/connection.rb
Overview
Instance Method Summary collapse
-
#initialize(host, port, wrap = false) ⇒ Connection
constructor
Create a new connection to the boogaloo server.
-
#method_missing(msg_id, *a, &b) ⇒ Object
Forwards all method calls to the server.
Constructor Details
#initialize(host, port, wrap = false) ⇒ Connection
Create a new connection to the boogaloo server.
Parameters:
hostThe host name or IP address to bind the socket to.
portThe port to bind the socket to.
wrapIf true, attempts to access the server when it is offline will result in a nil being returned instead of an exception being raised.
19 20 21 22 23 24 25 26 |
# File 'lib/boogaloo/client/connection.rb', line 19 def initialize(host, port, wrap=false) @wrap = wrap druby_str = "druby://#{host}:#{port}" DRb.start_service @conn = DRbObject.new(nil, druby_str) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg_id, *a, &b) ⇒ Object
Forwards all method calls to the server.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/boogaloo/client/connection.rb', line 29 def method_missing(msg_id, *a, &b) if @wrap begin return @conn.method_missing(msg_id, a, b) rescue DRb::DRbConnError return nil end else return @conn.method_missing(msg_id, a, b) end end |