ddp-server 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bea09aff73c8b4d3a6c902f7655876a21b3fa0b3
4
- data.tar.gz: a1bc3ea64efe95e99ddc72234d3ae93252783280
3
+ metadata.gz: d381599bc0830974575ae535e1fa50b5f59e60e0
4
+ data.tar.gz: b52845dc6398bd7889db47ad130aa119593024cb
5
5
  SHA512:
6
- metadata.gz: bc1f4362a5f92a148e69286d764544fb6858d16d0a956c46f442b62a6aaa36a84c32d1941391d608d758aa05acfbcb934e816642f8b9ffee3d5df0a7068554ca
7
- data.tar.gz: 7be2fd599ddd69981021393f8b0c896042a36c8892232790d89d52eb66a6b8341e40197c2c0f582996350068cefeff507e7dffbf5c8d2daeb91fbde8ee8ffd6f
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
@@ -1,6 +1,6 @@
1
1
  module DDP
2
2
  # We use semantic versioning
3
3
  module Server
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
6
6
  end
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.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-15 00:00:00.000000000 Z
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