active_remote 7.0.0 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{ruby.yml → main.yml} +15 -6
- data/.rubocop.yml +2 -27
- data/.standard.yml +2 -0
- data/CHANGES.md +190 -53
- data/README.md +6 -5
- data/Rakefile +2 -5
- data/active_remote.gemspec +17 -20
- data/lib/active_remote/association.rb +3 -3
- data/lib/active_remote/base.rb +12 -12
- data/lib/active_remote/dirty.rb +2 -2
- data/lib/active_remote/dsl.rb +14 -14
- data/lib/active_remote/integration.rb +7 -7
- data/lib/active_remote/persistence.rb +7 -7
- data/lib/active_remote/query_attributes.rb +3 -3
- data/lib/active_remote/rpc.rb +2 -3
- data/lib/active_remote/rpc_adapters/protobuf_adapter.rb +2 -2
- data/lib/active_remote/search.rb +25 -8
- data/lib/active_remote/serializers/protobuf.rb +10 -9
- data/lib/active_remote/validations.rb +2 -2
- data/lib/active_remote/version.rb +1 -1
- data/spec/lib/active_remote/association_spec.rb +25 -25
- data/spec/lib/active_remote/dirty_spec.rb +8 -8
- data/spec/lib/active_remote/dsl_spec.rb +7 -7
- data/spec/lib/active_remote/errors_spec.rb +2 -2
- data/spec/lib/active_remote/integration_spec.rb +2 -2
- data/spec/lib/active_remote/persistence_spec.rb +34 -34
- data/spec/lib/active_remote/primary_key_spec.rb +2 -2
- data/spec/lib/active_remote/rpc_adapters/protobuf_adapter_spec.rb +1 -1
- data/spec/lib/active_remote/rpc_spec.rb +13 -15
- data/spec/lib/active_remote/scope_keys_spec.rb +2 -2
- data/spec/lib/active_remote/search_spec.rb +31 -4
- data/spec/lib/active_remote/serialization_spec.rb +2 -2
- data/spec/lib/active_remote/serializers/protobuf_spec.rb +7 -7
- data/spec/lib/active_remote/validations_spec.rb +1 -1
- data/spec/support/models/author.rb +3 -3
- data/spec/support/models/category.rb +3 -3
- data/spec/support/models/default_author.rb +3 -3
- data/spec/support/models/post.rb +4 -4
- data/spec/support/protobuf/author.pb.rb +5 -11
- data/spec/support/protobuf/category.pb.rb +5 -11
- data/spec/support/protobuf/error.pb.rb +1 -6
- data/spec/support/protobuf/post.pb.rb +6 -12
- data/spec/support/protobuf/serializer.pb.rb +1 -8
- data/spec/support/protobuf/tag.pb.rb +5 -11
- metadata +29 -80
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92aae53e06ad0e55d689420b7efd5d7bbeb506bde19cd5e32ef2a5157fb9e163
|
4
|
+
data.tar.gz: 604eb816304b23dd82ca760192206d3b6e62a1cc188a647e5f8fb69589f99d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 435df01b39e8d571419743146b7941349f08d585505b4112d298fd670946e5565f5a78cbf595dcf699c7be809d5fac44e1e5f14a512d689a1cb85d0722b67d2c
|
7
|
+
data.tar.gz: cb2d8876f0aa28df71309ae3f53f2e4542ce4dddc6a428dc5c19d1c58d733fbbcf03a3b9afb14ccef33cdf17d29d39c6532595f1eea6ed138a03f4de94260d71
|
@@ -6,22 +6,31 @@
|
|
6
6
|
# GitHub recommends pinning actions to a commit SHA.
|
7
7
|
# To get a newer version, you will need to update the SHA.
|
8
8
|
# You can also reference a tag or branch, but the action may change without warning.
|
9
|
-
|
10
|
-
name: Ruby CI
|
9
|
+
name: ci
|
11
10
|
|
12
11
|
on:
|
13
12
|
push:
|
14
|
-
branches: [
|
13
|
+
branches: [main]
|
15
14
|
pull_request:
|
16
|
-
branches: [
|
15
|
+
branches: [main]
|
17
16
|
|
18
17
|
jobs:
|
18
|
+
lint:
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v4
|
22
|
+
- uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: "3.1"
|
25
|
+
bundler-cache: true
|
26
|
+
- run: bundle exec standardrb --parallel --format github
|
19
27
|
test:
|
20
28
|
runs-on: ubuntu-latest
|
21
29
|
strategy:
|
22
30
|
fail-fast: false
|
23
31
|
matrix:
|
24
|
-
ruby:
|
32
|
+
ruby:
|
33
|
+
[2.7, 3.0, 3.1, head, debug, jruby-9.4, jruby-head, truffleruby-head]
|
25
34
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
26
35
|
steps:
|
27
36
|
- uses: actions/checkout@v4
|
@@ -29,4 +38,4 @@ jobs:
|
|
29
38
|
with:
|
30
39
|
ruby-version: ${{ matrix.ruby }}
|
31
40
|
- run: bundle install
|
32
|
-
- run: bundle rspec
|
41
|
+
- run: bundle exec rspec
|
data/.rubocop.yml
CHANGED
@@ -1,28 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
---
|
3
2
|
inherit_gem:
|
4
|
-
|
5
|
-
|
6
|
-
# Styles that are modified from the defaults
|
7
|
-
AllCops:
|
8
|
-
TargetRubyVersion: 3.1
|
9
|
-
Exclude:
|
10
|
-
- "**/*.pb.rb"
|
11
|
-
|
12
|
-
Style/BlockDelimiters:
|
13
|
-
Description: >-
|
14
|
-
Avoid using {...} for multi-line blocks (multiline chaining is always ugly).
|
15
|
-
Prefer {...} over do...end for single-line blocks.
|
16
|
-
Exclude:
|
17
|
-
- "spec/**/*"
|
18
|
-
|
19
|
-
Style/HashSyntax:
|
20
|
-
Description: >-
|
21
|
-
Prefer Ruby 1.8 hash syntax { :a => 1, :b => 2 } over 1.9 syntax { a: 1, b: 2 }.
|
22
|
-
EnforcedStyle: hash_rockets
|
23
|
-
Exclude:
|
24
|
-
- "Gemfile"
|
25
|
-
|
26
|
-
Layout/SpaceAroundOperators:
|
27
|
-
Exclude:
|
28
|
-
- "*.gemspec"
|
3
|
+
standard: config/ruby-3.1.yml
|
data/.standard.yml
ADDED
data/CHANGES.md
CHANGED
@@ -1,80 +1,217 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
4
|
-
----------
|
3
|
+
All notable changes to this project will be documented in this file.
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
- Use query attributes from Active Record (string values such as 'FALSE', and '0' are now considered present) [#71]
|
9
|
-
- Drop support for Rails 4.2 (versions will match Rails version moving forward) [#71]
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
10
7
|
|
11
|
-
|
12
|
-
----------
|
8
|
+
## [Unreleased]
|
13
9
|
|
14
|
-
|
10
|
+
## [7.1.0] - 2024-12-04
|
15
11
|
|
16
|
-
|
17
|
-
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Update to ActiveModel 7.1 [#100](https://github.com/liveh2o/active_remote/pulls/100)
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Add `find_by` to the `Search` module to return the first record without raising `RemoteRecordNotFound` [#83](https://github.com/liveh2o/active_remote/pull/83)
|
19
|
+
|
20
|
+
## [7.0.0] - 2024-06-15
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- Update to ActiveModel 7.0 [#96](https://github.com/liveh2o/active_remote/pulls/96)
|
25
|
+
|
26
|
+
## [6.1.2] - 2024-06-15
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- Add Ruby 3.1 compatibility [9477268](https://github.com/liveh2o/active_remote/commit/9477268)
|
31
|
+
|
32
|
+
## [6.1.1] - 2022-09-07
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- Revert the reader and writer methods so they can be overridden [#95](https://github.com/liveh2o/active_remote/pull/95)
|
37
|
+
|
38
|
+
## [6.1.0] - 2022-08-24
|
39
|
+
|
40
|
+
### Changed
|
41
|
+
|
42
|
+
- Update to ActiveModel 6.1
|
43
|
+
|
44
|
+
## [6.0.3] - 2024-06-15
|
45
|
+
|
46
|
+
### Added
|
47
|
+
|
48
|
+
- Add Ruby 3.1 compatibility [45d8e26](https://github.com/liveh2o/active_remote/commit/45d8e26)
|
49
|
+
|
50
|
+
## [6.0.2] - 2022-06-17
|
51
|
+
|
52
|
+
### Fixed
|
53
|
+
|
54
|
+
- Fix association writer method (so it actually works) [85b369a](https://github.com/liveh2o/active_remote/commit/85b369a)
|
55
|
+
|
56
|
+
## [6.0.1] - 2022-02-11
|
57
|
+
|
58
|
+
### Changed
|
59
|
+
|
60
|
+
- Pin to ActiveModel 6.0 (specs fail under 6.1)
|
61
|
+
|
62
|
+
## [6.0.0]- 2022-02-10
|
63
|
+
|
64
|
+
### Changed
|
65
|
+
|
66
|
+
- Update to ActiveModel 6.x
|
67
|
+
|
68
|
+
## [5.2.0] - 2020-05-21
|
69
|
+
|
70
|
+
### Changed
|
71
|
+
|
72
|
+
- Update to ActiveModel 5.2 to get major speed gains [#68](https://github.com/liveh2o/active_remote/pull/68)
|
73
|
+
|
74
|
+
### Removed
|
75
|
+
|
76
|
+
- Drop support for Rails 5.1
|
77
|
+
- Remove development dependency on protobuf-nats
|
78
|
+
|
79
|
+
## [5.1.1] - 2019-04-16
|
80
|
+
|
81
|
+
### Changed
|
82
|
+
|
83
|
+
- Include response errors in RemoteRecordNotSaved exception [#75](https://github.com/liveh2o/active_remote/pull/75)
|
84
|
+
|
85
|
+
## [5.1.0] - 2019-01-26
|
86
|
+
|
87
|
+
### Removed
|
88
|
+
|
89
|
+
- Drop support for Rails 5.0
|
90
|
+
|
91
|
+
## [5.0.1] - 2019-04-16
|
92
|
+
|
93
|
+
### Changed
|
94
|
+
|
95
|
+
- Include response errors in RemoteRecordNotSaved exception [#75](https://github.com/liveh2o/active_remote/pull/75)
|
96
|
+
|
97
|
+
## [5.0.0] - 2019-01-26
|
98
|
+
|
99
|
+
### Added
|
100
|
+
|
101
|
+
- Use Active Model attributes [#72](https://github.com/liveh2o/active_remote/pull/72)
|
102
|
+
- Use type casting from Active Model (custom types must be registered) [#71](https://github.com/liveh2o/active_remote/pull/71)
|
103
|
+
- Use query attributes from Active Record (string values such as 'FALSE', and '0' are now considered present) [#71](https://github.com/liveh2o/active_remote/pull/71)
|
104
|
+
- Add ability to execute remote calls on current object [#74](https://github.com/liveh2o/active_remote/pull/74)
|
105
|
+
|
106
|
+
### Fixed
|
107
|
+
|
108
|
+
Make query attributes more permissive [#73](https://github.com/liveh2o/active_remote/pull/73)
|
109
|
+
|
110
|
+
### Removed
|
111
|
+
|
112
|
+
- Drop support for Rails 4.2 (versions will match Rails version moving forward) [#71](https://github.com/liveh2o/active_remote/pull/71)
|
113
|
+
|
114
|
+
## [3.3.3] - 2020-01-10
|
115
|
+
|
116
|
+
### Added
|
117
|
+
|
118
|
+
- Register big_integer type [#76](https://github.com/liveh2o/active_remote/pull/76)
|
119
|
+
|
120
|
+
## [3.3.2] - 2019-04-16
|
121
|
+
|
122
|
+
### Changed
|
123
|
+
|
124
|
+
- Include response errors in RemoteRecordNotSaved exception [#75](https://github.com/liveh2o/active_remote/pull/75)
|
125
|
+
|
126
|
+
## [3.3.1] - 2019-01-08
|
127
|
+
|
128
|
+
### Fixed
|
129
|
+
|
130
|
+
- Fix unknown type error in Protobuf serializer [#70](https://github.com/liveh2o/active_remote/pull/70)
|
131
|
+
|
132
|
+
## [3.3.0] - 2019-01-08
|
133
|
+
|
134
|
+
### Added
|
18
135
|
|
19
136
|
- Add support for registering types that can be used to define attributes without using the existing `:type` or
|
20
|
-
`:typecaster` options
|
137
|
+
`:typecaster` options `attribute :name, :string` [#69](https://github.com/liveh2o/active_remote/pull/69)
|
138
|
+
|
139
|
+
## [3.2.2] - 2018-12-31
|
21
140
|
|
22
|
-
|
23
|
-
----------
|
141
|
+
### Fixed
|
24
142
|
|
25
|
-
- Speed up boolean typecasting [#67, @abrandoned]
|
143
|
+
- Speed up boolean typecasting [#67, @abrandoned](https://github.com/liveh2o/active_remote/pull/67)
|
26
144
|
|
27
|
-
3.2.1
|
28
|
-
|
145
|
+
## [3.2.1] - 2018-11-11
|
146
|
+
|
147
|
+
### Changed
|
29
148
|
|
30
149
|
- Use `:remote_call` instead of of `rpc.execute` in persistence, search
|
31
150
|
|
32
|
-
3.2.0
|
33
|
-
|
151
|
+
## [3.2.0] - 2018-10-30
|
152
|
+
|
153
|
+
### Added
|
154
|
+
|
155
|
+
- Add ability to override default RPC endpoints [#66](https://github.com/liveh2o/active_remote/pull/66)
|
156
|
+
|
157
|
+
### Changed
|
34
158
|
|
35
|
-
- Add ability to override default RPC endpoints [#66]
|
36
159
|
- Require Active Model 4.x to 5.1 for compatibility
|
37
160
|
|
38
|
-
3.1.3
|
39
|
-
|
161
|
+
## [3.1.3] - 2018-07-10
|
162
|
+
|
163
|
+
### Changed
|
40
164
|
|
41
165
|
- Require Active Model 4.x for compatibility
|
42
|
-
- Cache and dup default attributes instead of building from scratch (4x speed boost on initialize) [#63, @film42]
|
43
166
|
|
44
|
-
|
45
|
-
|
167
|
+
### Fixed
|
168
|
+
|
169
|
+
- Cache and dup default attributes instead of building from scratch (4x speed boost on initialize) [#63, @film42](https://github.com/liveh2o/active_remote/pull/63)
|
170
|
+
|
171
|
+
## [3.1.2] - 2018-02-28
|
172
|
+
|
173
|
+
### Fixed
|
174
|
+
|
175
|
+
- Allow primary_key to be set on create [#61, @mattnichols](https://github.com/liveh2o/active_remote/pull/61)
|
176
|
+
- Change the behavior of DateTime types to gracefully handle invalid dates [#62, @brianstien](https://github.com/liveh2o/active_remote/pull/61)
|
177
|
+
|
178
|
+
## [3.1.1] - 2017-05-05
|
179
|
+
|
180
|
+
### Fixed
|
181
|
+
|
182
|
+
- Guard against undefined method errors in the Protobuf adapter [#59, @brianstien](https://github.com/liveh2o/active_remote/pull/59)
|
183
|
+
|
184
|
+
## [3.1.0] - 2017-04-27
|
185
|
+
|
186
|
+
### Added
|
187
|
+
|
188
|
+
- Bubble up the type of error given from Protobuf instead of a generic `ActiveRemoteError` [#58, @ryanbjones](https://github.com/liveh2o/active_remote/pull/58)
|
46
189
|
|
47
|
-
|
48
|
-
- Change the behavior of DateTime types to gracefully handle invalid dates [#62, @brianstien]
|
190
|
+
## [3.0.0] - 2017-03-02
|
49
191
|
|
50
|
-
|
51
|
-
----------
|
192
|
+
### Fixed
|
52
193
|
|
53
|
-
-
|
194
|
+
- Improve performance of many methods including `respond_to?` and `new`. [#50](https://github.com/liveh2o/active_remote/pull/50)
|
195
|
+
- Change to internals of typecasting. Declaring `attribute :name, :type => Integer`
|
196
|
+
will no longer affect performance negatively. [#56](https://github.com/liveh2o/active_remote/pull/56)
|
54
197
|
|
55
|
-
|
56
|
-
----------
|
198
|
+
### Changed
|
57
199
|
|
58
|
-
-
|
200
|
+
- Refactor of attribute storage internals [#50](https://github.com/liveh2o/active_remote/pull/50)
|
201
|
+
- Refactor of instantiate from RPC codepath [#56](https://github.com/liveh2o/active_remote/pull/56)
|
59
202
|
|
60
|
-
|
61
|
-
----------
|
203
|
+
### Removed
|
62
204
|
|
63
|
-
- Remove dependency on ActiveAttr [#48]
|
64
|
-
- Remove attribute defaults feature [#50]
|
65
|
-
- Remove core exts [#49]
|
205
|
+
- Remove dependency on ActiveAttr [#48](https://github.com/liveh2o/active_remote/pull/48)
|
206
|
+
- Remove attribute defaults feature [#50](https://github.com/liveh2o/active_remote/pull/50)
|
207
|
+
- Remove core exts [#49](https://github.com/liveh2o/active_remote/pull/49)
|
66
208
|
- Remove deprecated rpc methods `.request`, `.request_type`, #execute`, `#remote_call`
|
67
|
-
These methods are handled by the rpc adater now. [#49]
|
68
|
-
- Remove deprecated method `._active_remote_search_args` [#49]
|
69
|
-
- Remove deprecated `.parse_records` method [#49]
|
70
|
-
- Remove publication, `#publishable_hash` method [#49]
|
71
|
-
- Drop support for Rails 3 mass assignment protection.
|
72
|
-
enforcement for Rails 4+. [#50]
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
- Extracted bulk methods to active_remote-bulk [#54]
|
77
|
-
- Removed search callbacks [#55]
|
78
|
-
- Refactor of instantiate from rpc codepath [#56]
|
79
|
-
- Change to internals of typecasting. Declaring `attribute :name, :type => Integer`
|
80
|
-
will no longer affect performance negatively. [#56]
|
209
|
+
These methods are handled by the rpc adater now. [#49](https://github.com/liveh2o/active_remote/pull/49)
|
210
|
+
- Remove deprecated method `._active_remote_search_args` [#49](https://github.com/liveh2o/active_remote/pull/49)
|
211
|
+
- Remove deprecated `.parse_records` method [#49](https://github.com/liveh2o/active_remote/pull/49)
|
212
|
+
- Remove publication, `#publishable_hash` method [#49](https://github.com/liveh2o/active_remote/pull/49)
|
213
|
+
- Drop support for Rails 3 mass assignment protection. Add support for strong param
|
214
|
+
enforcement for Rails 4+. [#50](https://github.com/liveh2o/active_remote/pull/50)
|
215
|
+
- Remove a method that was doing dirty tracking twice [#52](https://github.com/liveh2o/active_remote/pull/52)
|
216
|
+
- Extracted bulk methods to active_remote-bulk [#54](https://github.com/liveh2o/active_remote/pull/54)
|
217
|
+
- Removed search callbacks [#55](https://github.com/liveh2o/active_remote/pull/55)
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
![CI](https://github.com/liveh2o/active_remote/actions/workflows/main.yml/badge.svg)
|
2
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/standardrb/standard)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/active_remote.svg)](https://badge.fury.io/rb/active_remote)
|
2
4
|
|
3
5
|
# Active Remote
|
4
6
|
|
@@ -6,7 +8,7 @@ Active Remote provides [Active Record](https://github.com/rails/rails/tree/maste
|
|
6
8
|
|
7
9
|
Active Remote provides a base class that when subclassed, provides the functionality you need to setup your remote model. Because Active Remote provides model persistence between RPC services, it uses a GUID to retrieve records and establish associations. So Active Remote expects your RPC data format to provide a :guid field that can be used to identify your remote models.
|
8
10
|
|
9
|
-
Unlike Active Record, Active Remote doesn't have access to a database table to create attribute mappings. So you'll need to do a little setup to let Active Remote know how to persist your model
|
11
|
+
Unlike Active Record, Active Remote doesn't have access to a database table to create attribute mappings. So you'll need to do a little setup to let Active Remote know how to persist your model\*.
|
10
12
|
|
11
13
|
```Ruby
|
12
14
|
# Given a product record that has :guid & :name fields:
|
@@ -21,7 +23,7 @@ Unlike Active Record, Active Remote doesn't have access to a database table to c
|
|
21
23
|
end
|
22
24
|
```
|
23
25
|
|
24
|
-
_
|
26
|
+
_\*Using Ruby's inherited hook, you could build an attribute mapper to setup your remote models for you._
|
25
27
|
|
26
28
|
Like Active Record, Active Remote relies heavily on naming conventions and standard CRUD actions. It expects models name to map to it's service (e.g Product => ProductService) and will infer the service name automatically.
|
27
29
|
|
@@ -50,7 +52,7 @@ Like Active Record, Active Remote relies heavily on naming conventions and stand
|
|
50
52
|
end
|
51
53
|
```
|
52
54
|
|
53
|
-
|
55
|
+
You can, of course override it if need be:
|
54
56
|
|
55
57
|
```Ruby
|
56
58
|
# If you have a custom service:
|
@@ -78,7 +80,6 @@ Or install it yourself as:
|
|
78
80
|
|
79
81
|
$ gem install active_remote
|
80
82
|
|
81
|
-
|
82
83
|
## Contributing
|
83
84
|
|
84
85
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -2,16 +2,13 @@
|
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
require "protobuf/tasks"
|
4
4
|
require "rspec/core/rake_task"
|
5
|
-
require "
|
6
|
-
|
7
|
-
desc "Run cops"
|
8
|
-
::RuboCop::RakeTask.new(:rubocop)
|
5
|
+
require "standard/rake"
|
9
6
|
|
10
7
|
desc "Run specs"
|
11
8
|
::RSpec::Core::RakeTask.new(:spec)
|
12
9
|
|
13
10
|
desc "Run cops and specs (default)"
|
14
|
-
task :
|
11
|
+
task default: [:standard, :spec]
|
15
12
|
|
16
13
|
desc "Remove protobuf definitions that have been compiled"
|
17
14
|
task :clean do
|
data/active_remote.gemspec
CHANGED
@@ -1,20 +1,17 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
4
2
|
require "active_remote/version"
|
5
3
|
|
6
4
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
s.authors
|
10
|
-
s.email
|
11
|
-
s.homepage
|
12
|
-
s.summary
|
13
|
-
s.description
|
5
|
+
s.name = "active_remote"
|
6
|
+
s.version = ActiveRemote::VERSION
|
7
|
+
s.authors = ["Adam Hutchison"]
|
8
|
+
s.email = ["liveh2o@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/liveh2o/active_remote"
|
10
|
+
s.summary = "Active Record for your platform"
|
11
|
+
s.description = "Active Remote provides Active Record-like object-relational mapping over RPC. It was written for use with Google Protocol Buffers, but could be extended to use any RPC data format."
|
14
12
|
|
15
|
-
s.files
|
16
|
-
s.
|
17
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
15
|
s.require_paths = ["lib"]
|
19
16
|
|
20
17
|
s.required_ruby_version = ">= 2.7.0"
|
@@ -22,20 +19,20 @@ Gem::Specification.new do |s|
|
|
22
19
|
##
|
23
20
|
# Dependencies
|
24
21
|
#
|
25
|
-
s.add_dependency "activemodel", "~> 7.0"
|
26
|
-
s.add_dependency "activesupport", "~> 7.0"
|
22
|
+
s.add_dependency "activemodel", "~> 7.1.0"
|
23
|
+
s.add_dependency "activesupport", "~> 7.1.0"
|
27
24
|
s.add_dependency "protobuf", ">= 3.0"
|
28
25
|
|
29
26
|
##
|
30
27
|
# Development Dependencies
|
31
28
|
#
|
32
|
-
s.add_development_dependency "
|
33
|
-
s.add_development_dependency "rspec", ">=
|
29
|
+
s.add_development_dependency "benchmark-ips"
|
30
|
+
s.add_development_dependency "protobuf-rspec", ">= 1.1.2"
|
31
|
+
s.add_development_dependency "pry"
|
34
32
|
s.add_development_dependency "rspec-its"
|
35
33
|
s.add_development_dependency "rspec-pride", ">= 3.1.0"
|
36
|
-
s.add_development_dependency "
|
37
|
-
s.add_development_dependency "pry"
|
38
|
-
s.add_development_dependency "protobuf-rspec", ">= 1.1.2"
|
34
|
+
s.add_development_dependency "rspec", ">= 3.3.0"
|
39
35
|
s.add_development_dependency "simplecov"
|
40
|
-
s.add_development_dependency "
|
36
|
+
s.add_development_dependency "standard"
|
37
|
+
s.add_development_dependency "rake"
|
41
38
|
end
|
@@ -131,10 +131,10 @@ module ActiveRemote
|
|
131
131
|
raise "Could not find attribute: '#{options[:scope]}' on #{associated_class}" unless associated_class.public_instance_methods.include?(options[:scope])
|
132
132
|
end
|
133
133
|
|
134
|
-
|
134
|
+
private
|
135
135
|
|
136
136
|
def create_association_writer(associated_klass, options = {})
|
137
|
-
define_method("#{associated_klass}=") do |new_value|
|
137
|
+
define_method(:"#{associated_klass}=") do |new_value|
|
138
138
|
raise "New value must be an array" if options[:has_many] == true && new_value.class != Array
|
139
139
|
|
140
140
|
instance_variable_set(:"@#{associated_klass}", new_value)
|
@@ -156,7 +156,7 @@ module ActiveRemote
|
|
156
156
|
instance_variable_set(:"@#{associated_klass}", value)
|
157
157
|
end
|
158
158
|
|
159
|
-
|
159
|
+
value
|
160
160
|
end
|
161
161
|
|
162
162
|
create_association_writer(associated_klass, options)
|
data/lib/active_remote/base.rb
CHANGED
@@ -43,7 +43,7 @@ module ActiveRemote
|
|
43
43
|
include ::ActiveRemote::Validations
|
44
44
|
include ::ActiveModel::Validations::Callbacks
|
45
45
|
|
46
|
-
define_model_callbacks :initialize, :
|
46
|
+
define_model_callbacks :initialize, only: :after
|
47
47
|
|
48
48
|
def initialize(attributes = {})
|
49
49
|
super
|
@@ -107,23 +107,23 @@ module ActiveRemote
|
|
107
107
|
# We check defined?(@attributes) not to issue warnings if the object is
|
108
108
|
# allocated but not initialized.
|
109
109
|
inspection = if defined?(@attributes) && @attributes
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
110
|
+
attribute_names.collect do |name, _|
|
111
|
+
if attribute?(name)
|
112
|
+
"#{name}: #{attribute_for_inspect(name)}"
|
113
|
+
else
|
114
|
+
name
|
115
|
+
end
|
116
|
+
end.compact.join(", ")
|
117
|
+
else
|
118
|
+
"not initialized"
|
119
|
+
end
|
120
120
|
|
121
121
|
"#<#{self.class} #{inspection}>"
|
122
122
|
end
|
123
123
|
|
124
124
|
# Returns a hash of the given methods with their names as keys and returned values as values.
|
125
125
|
def slice(*methods)
|
126
|
-
|
126
|
+
methods.flatten.map! { |method| [method, public_send(method)] }.to_h.with_indifferent_access
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
data/lib/active_remote/dirty.rb
CHANGED
@@ -62,7 +62,7 @@ module ActiveRemote
|
|
62
62
|
enable_dirty_tracking
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
private
|
66
66
|
|
67
67
|
# Wether or not changes are currently being tracked for this class.
|
68
68
|
#
|
@@ -74,7 +74,7 @@ module ActiveRemote
|
|
74
74
|
# ActiveModel::Dirty.
|
75
75
|
#
|
76
76
|
def attribute=(name, value)
|
77
|
-
send("#{name}_will_change!") if _active_remote_track_changes? && value != self[name]
|
77
|
+
send(:"#{name}_will_change!") if _active_remote_track_changes? && value != self[name]
|
78
78
|
super
|
79
79
|
end
|
80
80
|
|
data/lib/active_remote/dsl.rb
CHANGED
@@ -20,32 +20,32 @@ module ActiveRemote
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def endpoint_for_create(endpoint)
|
23
|
-
endpoints :
|
23
|
+
endpoints create: endpoint
|
24
24
|
end
|
25
25
|
|
26
26
|
def endpoint_for_delete(endpoint)
|
27
|
-
endpoints :
|
27
|
+
endpoints delete: endpoint
|
28
28
|
end
|
29
29
|
|
30
30
|
def endpoint_for_destroy(endpoint)
|
31
|
-
endpoints :
|
31
|
+
endpoints destroy: endpoint
|
32
32
|
end
|
33
33
|
|
34
34
|
def endpoint_for_search(endpoint)
|
35
|
-
endpoints :
|
35
|
+
endpoints search: endpoint
|
36
36
|
end
|
37
37
|
|
38
38
|
def endpoint_for_update(endpoint)
|
39
|
-
endpoints :
|
39
|
+
endpoints update: endpoint
|
40
40
|
end
|
41
41
|
|
42
42
|
def endpoints(endpoints_hash = nil)
|
43
43
|
@endpoints ||= {
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
44
|
+
create: :create,
|
45
|
+
delete: :delete,
|
46
|
+
destroy: :destroy,
|
47
|
+
search: :search,
|
48
|
+
update: :update
|
49
49
|
}
|
50
50
|
@endpoints.merge!(endpoints_hash) if endpoints_hash.present?
|
51
51
|
@endpoints
|
@@ -114,7 +114,7 @@ module ActiveRemote
|
|
114
114
|
@service_name ||= _determine_service_name
|
115
115
|
end
|
116
116
|
|
117
|
-
|
117
|
+
private
|
118
118
|
|
119
119
|
# Combine the namespace and service values, constantize them and return
|
120
120
|
# the class constant.
|
@@ -127,12 +127,12 @@ module ActiveRemote
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def _determine_service_name
|
130
|
-
underscored_name =
|
131
|
-
"#{underscored_name}_service"
|
130
|
+
underscored_name = name.underscore
|
131
|
+
:"#{underscored_name}_service"
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
-
|
135
|
+
private
|
136
136
|
|
137
137
|
# Private convenience methods for accessing DSL methods in instances
|
138
138
|
#
|