ddp-server 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ddp/server/api.rb +42 -0
- data/lib/ddp/server/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d381599bc0830974575ae535e1fa50b5f59e60e0
|
4
|
+
data.tar.gz: b52845dc6398bd7889db47ad130aa119593024cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6624725bcbb737fa6190019b29bdc8d3b8902aa80346fcd2a7c3f325ec770307c4e876db1e517f8f5ac7408a2ca86b9e47199c287e41a781c76c7d2bec4ca20b
|
7
|
+
data.tar.gz: a27947f898eb06e4695e194ab3c5d16ea5e808deb107751259edc93cc8ef806829d89f54adc8c8ef229cd4b2cece588d026529516be74f3b8ef49277f9b0aaa8
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module DDP
|
2
|
+
module Server
|
3
|
+
# Helper class that users can extend to implement an API that can be passed
|
4
|
+
# as the RPC API parameter to the RethinkDB DDP protocol
|
5
|
+
class API
|
6
|
+
def initialize
|
7
|
+
setup_rpc
|
8
|
+
setup_collections
|
9
|
+
end
|
10
|
+
|
11
|
+
def invoke_rpc(method, *params)
|
12
|
+
raise 'No such method' unless @rpc_methods.include? method
|
13
|
+
send(method, *params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def collection_query(name, *params)
|
17
|
+
raise 'No such collection' unless @collections.include? name
|
18
|
+
wrap_query(send(name, *params))
|
19
|
+
end
|
20
|
+
|
21
|
+
# Implementors must override wrap_query. The argument is a query that is to be executed
|
22
|
+
# the result should be a proc that yields data values to its block parameter.
|
23
|
+
def wrap_query(query)
|
24
|
+
raise 'implement wrap query'
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def setup_rpc
|
30
|
+
rpc_module = self.class.const_get :RPC
|
31
|
+
@rpc_methods = rpc_module.instance_methods.map(&:to_s)
|
32
|
+
singleton_class.include rpc_module
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup_collections
|
36
|
+
collections_module = self.class.const_get :Collections
|
37
|
+
@collections = collections_module.instance_methods.map(&:to_s)
|
38
|
+
singleton_class.include collections_module
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/ddp/server/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddp-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tinco Andringa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- examples/rack_example.ru
|
71
71
|
- lib/ddp/ejson.rb
|
72
72
|
- lib/ddp/server.rb
|
73
|
+
- lib/ddp/server/api.rb
|
73
74
|
- lib/ddp/server/protocol.rb
|
74
75
|
- lib/ddp/server/protocol/data.rb
|
75
76
|
- lib/ddp/server/protocol/heartbeat.rb
|