protobuf-activerecord 3.1.0.alpha2 → 3.1.0.rc1

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: e93c8167f34b38c4158dd3d82db152c09e416627
4
- data.tar.gz: 555cce2e9b32877a021ae999bf1218cc6ebf9ac1
3
+ metadata.gz: f42ba3a9157a8f65d92959c296f5bb19fa168ee2
4
+ data.tar.gz: e468d159988120ea8ea0fedc6e38078c0713f568
5
5
  SHA512:
6
- metadata.gz: 9c68fe645bc4fc2bc77f3fbf71695f48f927314e5fff2c870431cc3e8a22f39c003d354de5c39b887255bcdd75751004ef1f2dc952e33d1522ae81908a519010
7
- data.tar.gz: 24aa0aacbcc8fe1fa5c8e4c8f88752e133ae32cbc819d58ff237e5416a8f18bbb22b641c4e62314b6e1991681ffb5b3b1c172df4d425f4ae290f378951e361af
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 = "rprotoc --ruby_out=spec/support/protobuf --proto_path=spec/support/definitions spec/support/definitions/*.proto"
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
- on_inherit do
14
- include Protobuf::ActiveRecord::ServiceFilters
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
@@ -74,7 +74,7 @@ module Protobuf
74
74
  end
75
75
 
76
76
  values = [ value ].flatten
77
- values.map!(&:to_i) if proto.get_field_by_name(field).enum?
77
+ values.map!(&:to_i) if proto.class.get_field(field, true).enum?
78
78
  values
79
79
  end
80
80
 
@@ -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.get_field_by_name(key) || proto.get_ext_field_by_name(key)
31
+ field = proto.class.get_field(key, true)
32
32
  proto.has_field?(key) && !field.repeated?
33
33
  end
34
34
 
@@ -30,7 +30,7 @@ module Protobuf
30
30
  raise ArgumentError, ":with must be specified" if enumerable.nil?
31
31
 
32
32
  if enumerable < ::Protobuf::Enum
33
- options[:in] = enumerable.values.values.map(&:value)
33
+ options[:in] = enumerable.all_tags
34
34
  end
35
35
 
36
36
  args << options
@@ -1,5 +1,5 @@
1
1
  module Protobuf
2
2
  module ActiveRecord
3
- VERSION = "3.1.0.alpha2"
3
+ VERSION = "3.1.0.rc1"
4
4
  end
5
5
  end
@@ -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", ">= 2.2.0"
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 ::Protobuf::Field::StringField, :guid, 1
19
- optional ::Protobuf::Field::StringField, :name, 2
20
- optional ::Protobuf::Field::StringField, :email, 3
21
- optional ::Protobuf::Field::StringField, :email_domain, 4, :deprecated => true
22
- optional ::Protobuf::Field::StringField, :password, 5
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 ::Protobuf::Field::StringField, :guid, 1
27
- repeated ::Protobuf::Field::StringField, :email, 2
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.alpha2
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-01-30 00:00:00.000000000 Z
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: 2.2.0
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: 2.2.0
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.1.11
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