protobuf-activerecord 5.0.0.beta → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +1 -1
- data/lib/protobuf/active_record/persistence.rb +14 -0
- data/lib/protobuf/active_record/version.rb +1 -1
- data/protobuf-activerecord.gemspec +3 -3
- data/spec/protobuf/active_record/persistence_spec.rb +24 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca3093ed9fc08a78613d199d77d48cfe34dbbde2cf7eb023abb41e44920fbae
|
4
|
+
data.tar.gz: 8c0625f0a320ce5d22ed5fc007394815bffad6025a3762269e092fd3a92e9b06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9e2a92494d57083f5192476be58cf0ffff537cda7e2cf45c5543d7f458ab3c343296a5c13b9d431ae7893b07ecc1f697d94c26ac1fd623dec8003f0a6372c20
|
7
|
+
data.tar.gz: ffce90418d59cf8baa92156d65c4d123cc7ae8c41e97aa7da7450c9b6d46420999b36df61de67f27150b3cb0246d6b063fefa254928d0b1cb3a8838ff9362ec7
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -158,7 +158,7 @@ end
|
|
158
158
|
|
159
159
|
### Attribute transformers
|
160
160
|
|
161
|
-
Protobuf Active Record handles mapping protobuf message fields to object attributes, but what happens when an attribute doesn't have a matching field? Using the `attribute_from_proto` method, you can define custom attribute transformations. Simply call `
|
161
|
+
Protobuf Active Record handles mapping protobuf message fields to object attributes, but what happens when an attribute doesn't have a matching field? Using the `attribute_from_proto` method, you can define custom attribute transformations. Simply call `attribute_from_proto`, passing it the name of the attribute and a method name or callable (lambda or proc). When creating or updating objects, the transformer will be called and passed the protobuf message.
|
162
162
|
|
163
163
|
```Ruby
|
164
164
|
class User < ActiveRecord::Base
|
@@ -37,6 +37,20 @@ module Protobuf
|
|
37
37
|
super(attributes)
|
38
38
|
end
|
39
39
|
|
40
|
+
# :nodoc:
|
41
|
+
def update(attributes)
|
42
|
+
attributes = attributes_from_proto(attributes) if attributes.is_a?(::Protobuf::Message)
|
43
|
+
|
44
|
+
super(attributes)
|
45
|
+
end
|
46
|
+
|
47
|
+
# :nodoc:
|
48
|
+
def update!(attributes)
|
49
|
+
attributes = attributes_from_proto(attributes) if attributes.is_a?(::Protobuf::Message)
|
50
|
+
|
51
|
+
super(attributes)
|
52
|
+
end
|
53
|
+
|
40
54
|
# :nodoc:
|
41
55
|
def update_attributes(attributes)
|
42
56
|
attributes = attributes_from_proto(attributes) if attributes.is_a?(::Protobuf::Message)
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
##
|
23
23
|
# Dependencies
|
24
24
|
#
|
25
|
-
spec.add_dependency "activerecord", "~>
|
26
|
-
spec.add_dependency "activesupport", "~>
|
25
|
+
spec.add_dependency "activerecord", "~> 6.0.0"
|
26
|
+
spec.add_dependency "activesupport", "~> 6.0.0"
|
27
27
|
spec.add_dependency "concurrent-ruby"
|
28
28
|
spec.add_dependency "heredity", ">= 0.1.1"
|
29
29
|
spec.add_dependency "protobuf", ">= 3.0"
|
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "rspec-pride", ">= 3.1.0"
|
39
39
|
spec.add_development_dependency "pry-nav"
|
40
40
|
spec.add_development_dependency "simplecov"
|
41
|
-
spec.add_development_dependency "sqlite3"
|
41
|
+
spec.add_development_dependency "sqlite3", ">= 1.4"
|
42
42
|
spec.add_development_dependency "timecop"
|
43
43
|
end
|
@@ -67,4 +67,28 @@ describe Protobuf::ActiveRecord::Persistence do
|
|
67
67
|
user.update_attributes!(user_attributes)
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
describe "#update" do
|
72
|
+
it "accepts a protobuf message" do
|
73
|
+
expect_any_instance_of(User).to receive(:save)
|
74
|
+
user.update(proto)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "accepts a hash" do
|
78
|
+
expect_any_instance_of(User).to receive(:save)
|
79
|
+
user.update(user_attributes)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#update!" do
|
84
|
+
it "accepts a protobuf message" do
|
85
|
+
expect_any_instance_of(User).to receive(:save!)
|
86
|
+
user.update!(proto)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "accepts a hash" do
|
90
|
+
expect_any_instance_of(User).to receive(:save!)
|
91
|
+
user.update!(user_attributes)
|
92
|
+
end
|
93
|
+
end
|
70
94
|
end
|
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:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hutchison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: concurrent-ruby
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
187
|
+
version: '1.4'
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
194
|
+
version: '1.4'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: timecop
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,11 +271,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
271
|
version: '0'
|
272
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
273
273
|
requirements:
|
274
|
-
- - "
|
274
|
+
- - ">="
|
275
275
|
- !ruby/object:Gem::Version
|
276
|
-
version:
|
276
|
+
version: '0'
|
277
277
|
requirements: []
|
278
|
-
rubygems_version: 3.
|
278
|
+
rubygems_version: 3.1.2
|
279
279
|
signing_key:
|
280
280
|
specification_version: 4
|
281
281
|
summary: Google Protocol Buffers integration for Active Record
|