protobuf-activerecord 3.1.0.alpha2 → 3.1.0.rc1
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/Rakefile +1 -1
- data/lib/protobuf-activerecord.rb +2 -1
- data/lib/protobuf/active_record/middleware/connection_management.rb +17 -0
- data/lib/protobuf/active_record/middleware/query_cache.rb +29 -0
- data/lib/protobuf/active_record/railtie.rb +2 -3
- data/lib/protobuf/active_record/scope.rb +1 -1
- data/lib/protobuf/active_record/transformation.rb +1 -1
- data/lib/protobuf/active_record/validations.rb +1 -1
- data/lib/protobuf/active_record/version.rb +1 -1
- data/protobuf-activerecord.gemspec +1 -1
- data/spec/support/protobuf/user.pb.rb +7 -7
- metadata +7 -6
- data/lib/protobuf/active_record/service_filters.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f42ba3a9157a8f65d92959c296f5bb19fa168ee2
|
4
|
+
data.tar.gz: e468d159988120ea8ea0fedc6e38078c0713f568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59c81886e81abc07b51488a85edc4d27f5a5025d1444e3790893c2bfd47696b67c4208a98abaabbd06ca3236c3f8e885b2a021c6fd4b0e48a6f770defa6c3bf6
|
7
|
+
data.tar.gz: ea61d1a46bb287bf3880b9c9345f4c4bd9bc96c5474e221d036f28bf817c7630656d9c7f4453d65701fe0ab11f35b2745bbca378ca822f310eee3fa8fe5b222c
|
data/Rakefile
CHANGED
@@ -15,6 +15,6 @@ end
|
|
15
15
|
|
16
16
|
desc "Compile spec/support protobuf definitions"
|
17
17
|
task :compile, [] => :clean do
|
18
|
-
cmd = "
|
18
|
+
cmd = "protoc --ruby_out=spec/support/protobuf --proto_path=spec/support/definitions spec/support/definitions/*.proto"
|
19
19
|
sh(cmd)
|
20
20
|
end
|
@@ -12,8 +12,9 @@ rescue LoadError
|
|
12
12
|
end
|
13
13
|
|
14
14
|
require 'protobuf/active_record/config'
|
15
|
+
require 'protobuf/active_record/middleware/connection_management'
|
16
|
+
require 'protobuf/active_record/middleware/query_cache'
|
15
17
|
require 'protobuf/active_record/model'
|
16
|
-
require 'protobuf/active_record/service_filters'
|
17
18
|
require 'protobuf/active_record/version'
|
18
19
|
|
19
20
|
module Protobuf
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Protobuf
|
2
|
+
module ActiveRecord
|
3
|
+
module Middleware
|
4
|
+
class ConnectionManagement
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
@app.call(env)
|
11
|
+
ensure
|
12
|
+
::ActiveRecord::Base.clear_active_connections!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Protobuf
|
2
|
+
module ActiveRecord
|
3
|
+
module Middleware
|
4
|
+
class QueryCache
|
5
|
+
def initialize(app)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
enabled = ::ActiveRecord::Base.connection.query_cache_enabled
|
11
|
+
connection_id = ::ActiveRecord::Base.connection_id
|
12
|
+
::ActiveRecord::Base.connection.enable_query_cache!
|
13
|
+
|
14
|
+
@app.call(env)
|
15
|
+
ensure
|
16
|
+
restore_query_cache_settings(connection_id, enabled)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def restore_query_cache_settings(connection_id, enabled)
|
22
|
+
::ActiveRecord::Base.connection_id = connection_id
|
23
|
+
::ActiveRecord::Base.connection.clear_query_cache
|
24
|
+
::ActiveRecord::Base.connection.disable_query_cache! unless enabled
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -10,9 +10,8 @@ module Protobuf
|
|
10
10
|
end
|
11
11
|
|
12
12
|
ActiveSupport.on_load(:protobuf_rpc_service) do
|
13
|
-
|
14
|
-
|
15
|
-
end
|
13
|
+
Protobuf::Rpc.middleware.insert_after Protobuf::Rpc::Middleware::Logger, Middleware::ConnectionManagement
|
14
|
+
Protobuf::Rpc.middleware.insert_after Middleware::ConnectionManagement, Middleware::QueryCache
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -28,7 +28,7 @@ module Protobuf
|
|
28
28
|
def _filter_attribute_fields(proto)
|
29
29
|
fields = proto.to_hash
|
30
30
|
fields.select! do |key, value|
|
31
|
-
field = proto.
|
31
|
+
field = proto.class.get_field(key, true)
|
32
32
|
proto.has_field?(key) && !field.repeated?
|
33
33
|
end
|
34
34
|
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "activerecord", ">= 3.2.0"
|
25
25
|
spec.add_dependency "activesupport", ">= 3.2.0"
|
26
26
|
spec.add_dependency "heredity", ">= 0.1.1"
|
27
|
-
spec.add_dependency "protobuf", ">=
|
27
|
+
spec.add_dependency "protobuf", ">= 3.0.0.rc1"
|
28
28
|
|
29
29
|
##
|
30
30
|
# Development dependencies
|
@@ -15,15 +15,15 @@ class UserSearchMessage < ::Protobuf::Message; end
|
|
15
15
|
# Message Fields
|
16
16
|
#
|
17
17
|
class UserMessage
|
18
|
-
optional
|
19
|
-
optional
|
20
|
-
optional
|
21
|
-
optional
|
22
|
-
optional
|
18
|
+
optional :string, :guid, 1
|
19
|
+
optional :string, :name, 2
|
20
|
+
optional :string, :email, 3
|
21
|
+
optional :string, :email_domain, 4, :deprecated => true
|
22
|
+
optional :string, :password, 5
|
23
23
|
end
|
24
24
|
|
25
25
|
class UserSearchMessage
|
26
|
-
repeated
|
27
|
-
repeated
|
26
|
+
repeated :string, :guid, 1
|
27
|
+
repeated :string, :email, 2
|
28
28
|
end
|
29
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protobuf-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.0.
|
4
|
+
version: 3.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hutchison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.0.rc1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.0.0.rc1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,13 +186,14 @@ files:
|
|
186
186
|
- lib/protobuf/active_record/mass_assignment_security.rb
|
187
187
|
- lib/protobuf/active_record/mass_assignment_security/persistence.rb
|
188
188
|
- lib/protobuf/active_record/mass_assignment_security/transformation.rb
|
189
|
+
- lib/protobuf/active_record/middleware/connection_management.rb
|
190
|
+
- lib/protobuf/active_record/middleware/query_cache.rb
|
189
191
|
- lib/protobuf/active_record/model.rb
|
190
192
|
- lib/protobuf/active_record/nested_attributes.rb
|
191
193
|
- lib/protobuf/active_record/persistence.rb
|
192
194
|
- lib/protobuf/active_record/railtie.rb
|
193
195
|
- lib/protobuf/active_record/scope.rb
|
194
196
|
- lib/protobuf/active_record/serialization.rb
|
195
|
-
- lib/protobuf/active_record/service_filters.rb
|
196
197
|
- lib/protobuf/active_record/transformation.rb
|
197
198
|
- lib/protobuf/active_record/validations.rb
|
198
199
|
- lib/protobuf/active_record/version.rb
|
@@ -230,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
231
|
version: 1.3.1
|
231
232
|
requirements: []
|
232
233
|
rubyforge_project:
|
233
|
-
rubygems_version: 2.
|
234
|
+
rubygems_version: 2.2.2
|
234
235
|
signing_key:
|
235
236
|
specification_version: 4
|
236
237
|
summary: Google Protocol Buffers integration for Active Record
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Protobuf
|
2
|
-
module ActiveRecord
|
3
|
-
module ServiceFilters
|
4
|
-
extend ::ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
after_filter :_protobuf_active_record_clear_active_connections
|
8
|
-
end
|
9
|
-
|
10
|
-
def _protobuf_active_record_clear_active_connections
|
11
|
-
::ActiveRecord::Base.clear_active_connections!
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|