Class: Orator::Client
- Inherits:
-
Object
- Object
- Orator::Client
- Defined in:
- lib/orator/client.rb
Overview
A representation of a client.
Instance Attribute Summary collapse
-
#context ⇒ Object
The context to be used by the client.
-
#event_handler ⇒ EventHandler
The event handler for this client.
-
#socket ⇒ #send
The socket to be used to talk to the client.
Instance Method Summary collapse
-
#initialize(data) ⇒ Client
constructor
Initialize.
-
#to_hash ⇒ Hash
This is here just in case anyone gets the bright idea to serialize the client with Oj.
-
#trigger(event, *args) ⇒ Object
This forwards the method call to [EventHandler#trigger], but removes an argument: the context.
Constructor Details
#initialize(data) ⇒ Client
Initialize.
29 30 31 32 33 |
# File 'lib/orator/client.rb', line 29 def initialize(data) data.each do |k, v| send "#{k}=", v if respond_to? "#{k}=" end end |
Instance Attribute Details
#context ⇒ Object
The context to be used by the client.
14 15 16 |
# File 'lib/orator/client.rb', line 14 def context @context end |
#event_handler ⇒ EventHandler
The event handler for this client.
9 10 11 |
# File 'lib/orator/client.rb', line 9 def event_handler @event_handler end |
#socket ⇒ #send
The socket to be used to talk to the client.
19 20 21 |
# File 'lib/orator/client.rb', line 19 def socket @socket end |
Instance Method Details
#to_hash ⇒ Hash
This is here just in case anyone gets the bright idea to serialize the client with Oj. This should not happen, because it could reveal information that you may not want to be revealed.
48 49 50 |
# File 'lib/orator/client.rb', line 48 def to_hash context.table end |
#trigger(event, *args) ⇒ Object
This forwards the method call to [EventHandler#trigger], but removes an argument: the context.
39 40 41 |
# File 'lib/orator/client.rb', line 39 def trigger(event, *args) event_handler.trigger(event, context, *args) end |