Class: Metybur::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/metybur/client.rb
Instance Method Summary
collapse
Constructor Details
#initialize(websocket) ⇒ Client
Returns a new instance of Client.
6
7
8
|
# File 'lib/metybur/client.rb', line 6
def initialize(websocket)
@websocket = websocket
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *params, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/metybur/client.rb', line 31
def method_missing(method, *params, &block)
method = method.to_s.camelize(:lower)
params.map! do |param|
case param
when Hash
param_array = param.map { |k, v| [k.to_s.camelize(:lower), v] }
Hash[param_array]
else
param
end
end
call(method, params, &block)
end
|
Instance Method Details
#call(method_name, params, &block) ⇒ Object
27
28
29
|
# File 'lib/metybur/client.rb', line 27
def call(method_name, params, &block)
method(method_name).call(params, &block)
end
|
#collection(name) ⇒ Object
19
20
21
|
# File 'lib/metybur/client.rb', line 19
def collection(name)
Metybur::Collection.new(name, @websocket)
end
|
#method(name) ⇒ Object
23
24
25
|
# File 'lib/metybur/client.rb', line 23
def method(name)
Metybur::Method.new(name, @websocket)
end
|
#subscribe(record_set_name) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/metybur/client.rb', line 10
def subscribe(record_set_name)
message = {
msg: 'sub',
id: 'cde',
name: record_set_name
}.to_json
@websocket.send message
end
|