ddp-server-rethinkdb 0.1.0 → 0.1.1

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: fc02ef7ca06554ea7ef61095ca1f68b2216bbcfa
4
- data.tar.gz: d639840e48515eb7b9a22dfe11098503c8b4c28e
3
+ metadata.gz: 34f2534576cce64d35a055ef32b002efbc77eaf0
4
+ data.tar.gz: a4d7f07d0496189f5ab914e0fe6d26d494fe759f
5
5
  SHA512:
6
- metadata.gz: 9b8917caf19f51fdfb2fce59a5d8083732c3208fccd98280328f3b4ff61622ebff32e911540b6e09170ffc229c10be67ad43bd8b792dd106fc1705701d4bfdc9
7
- data.tar.gz: cc39c1677ef4ef5818ee930c476c8be648b9c96b8b7fcabfe7185ce956537889c30b822cb7d299388bad47ea739e48bcc35724f5c371af521aeef78466ae90b9
6
+ metadata.gz: 6f4d65ee2916787ddf9e456ac2365336c8d416d9157c0be269848df996d5f770e33234aef814a9b3b73278c933617b375c0b420be04e1234b8a50ce03205fc3d
7
+ data.tar.gz: 78f092738fb1e64407f566ccff037cb403874fd220b5689442059dea792d6344e45ca60414cf8c31b3bbe2d98bbe5b158424a7c56089f1b93d5b1432f3f34529
@@ -2,7 +2,7 @@ require 'rethinkdb'
2
2
  require 'connection_pool'
3
3
  require 'celluloid'
4
4
  require 'ddp/server'
5
- require 'ddp/server/rethinkdb'
5
+ require 'ddp/server/rethinkdb/helpers'
6
6
  require 'ddp/server/rethinkdb/api'
7
7
 
8
8
  module DDP
@@ -5,6 +5,8 @@ module DDP
5
5
  # Helper class that users can extend to implement an API that can be passed
6
6
  # as the RPC API parameter to the RethinkDB DDP protocol
7
7
  class API
8
+ include Helpers
9
+
8
10
  attr_accessor :database_name
9
11
 
10
12
  def initialize(config)
@@ -23,7 +25,7 @@ module DDP
23
25
 
24
26
  def collection_query(name, *params)
25
27
  raise 'No such collection' unless @collections.include? name
26
- wrap_query send(name, *params)
28
+ wrap_query(send(name, *params), new_connection)
27
29
  end
28
30
 
29
31
  def database
@@ -69,23 +71,6 @@ module DDP
69
71
  @collections = collections_module.instance_methods.map(&:to_s)
70
72
  singleton_class.include collections_module
71
73
  end
72
-
73
- def wrap_query(query)
74
- lambda do |&on_update|
75
- connection = new_connection
76
- results = query.run(connection)
77
- results.each { |r| on_update.call(nil, r) }
78
- wrap_changes(query, connection, on_update)
79
- end
80
- end
81
-
82
- def wrap_changes(query, conn, on_update)
83
- query.changes().run(conn).each do |change|
84
- old_value = change['old_val']
85
- new_value = change['new_val']
86
- on_update.call(old_value, new_value)
87
- end
88
- end
89
74
  end
90
75
  end
91
76
  end
@@ -0,0 +1,28 @@
1
+ module DDP
2
+ module Server
3
+ # A RethinkDB DDP Server implementation
4
+ module RethinkDB
5
+ # Helper class that users can extend to implement an API that can be passed
6
+ # as the RPC API parameter to the RethinkDB DDP protocol
7
+ module Helpers
8
+ def wrap_query(query, connection)
9
+ lambda do |&on_update|
10
+ connection = new_connection
11
+ results = query.run(connection)
12
+ results.each { |r| on_update.call(nil, r) }
13
+ wrap_changes(query, connection, on_update)
14
+ end
15
+ end
16
+
17
+ def wrap_changes(query, conn, on_update)
18
+ query.changes().run(conn).each do |change|
19
+ old_value = change['old_val']
20
+ new_value = change['new_val']
21
+ on_update.call(old_value, new_value)
22
+ end
23
+ conn.close
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,7 +2,7 @@ module DDP
2
2
  module Server
3
3
  # Include the version
4
4
  module RethinkDB
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddp-server-rethinkdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-16 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,6 +98,7 @@ files:
98
98
  - examples/messages.rb
99
99
  - lib/ddp/server/rethinkdb.rb
100
100
  - lib/ddp/server/rethinkdb/api.rb
101
+ - lib/ddp/server/rethinkdb/helpers.rb
101
102
  - lib/ddp/server/rethinkdb/version.rb
102
103
  homepage: https://github.com/d-snp/ruby-ddp-server-rethinkdb
103
104
  licenses: