mobility 1.3.0.rc2 → 1.3.0.rc3
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +14 -1
- data/README.md +2 -7
- data/lib/mobility/backends/active_record/table.rb +7 -1
- data/lib/mobility/plugins/active_model/dirty.rb +13 -3
- data/lib/mobility/version.rb +1 -1
- data/lib/mobility.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +23 -23
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd0b53980f62d9538827053f6e08b8ffd287d44a7a4aa87602c5d85e87bf30fc
|
4
|
+
data.tar.gz: 540af4290175ec08b109a8cc0e783c1a634c66fe87bf97fd014d5c5a0f78b79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25fc7f6a40125020f7425691a3d183a290bfaa3381594d1ad218a924797a0329f76ca39494742f380a3310fbe9d3c879849e366de20bd695219b247c90161d17
|
7
|
+
data.tar.gz: 8b02e9620070979a64e71d2774495a1be0054e92180116e4e40790575d05faff38fb78001ab460581de2524598af3823f312734b67804d2debe1de428737801a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,22 @@
|
|
2
2
|
|
3
3
|
## 1.3
|
4
4
|
|
5
|
+
### 1.3.0.rc3
|
6
|
+
|
7
|
+
- Don't try to load generators if Rails is loaded but AR is not
|
8
|
+
([#627](https://github.com/shioyama/mobility/pull/627)), thanks
|
9
|
+
[flop](https://github.com/flop)!
|
10
|
+
- Allow compound foreign keys
|
11
|
+
([#632](https://github.com/shioyama/mobility/pull/632)), thanks
|
12
|
+
[mival](https://github.com/mival)!
|
13
|
+
- Fix active model `*_previously_changed?` and active record
|
14
|
+
`will_save_change_to_*?` and `saved_change_to_*?` dirty methods to accept
|
15
|
+
kwargs ([#639](https://github.com/shioyama/mobility/pull/639)) thanks
|
16
|
+
[doits](https://github.com/doits)!
|
17
|
+
|
5
18
|
### 1.3.0.rc2
|
6
19
|
|
7
|
-
- Pass `coder` as keyword argument to `serialize` (ActiveRecord version >
|
20
|
+
- Pass `coder` as keyword argument to `serialize` (ActiveRecord version > 7.1)
|
8
21
|
([#617](https://github.com/shioyama/mobility/pull/617))
|
9
22
|
|
10
23
|
### 1.3.0.rc1
|
data/README.md
CHANGED
@@ -4,7 +4,6 @@ Mobility
|
|
4
4
|
[][gem]
|
5
5
|
[][actions]
|
6
6
|
[][codeclimate]
|
7
|
-
[](https://gitter.im/mobility-ruby/mobility)
|
8
7
|
|
9
8
|
[gem]: https://rubygems.org/gems/mobility
|
10
9
|
[actions]: https://github.com/shioyama/mobility/actions
|
@@ -55,17 +54,13 @@ Installation
|
|
55
54
|
Add this line to your application's Gemfile:
|
56
55
|
|
57
56
|
```ruby
|
58
|
-
gem 'mobility', '~> 1.3.0.
|
57
|
+
gem 'mobility', '~> 1.3.0.rc3'
|
59
58
|
```
|
60
59
|
|
61
60
|
### ActiveRecord (Rails)
|
62
61
|
|
63
62
|
Requirements:
|
64
|
-
- ActiveRecord >=
|
65
|
-
|
66
|
-
(Support for most backends and features is also supported with
|
67
|
-
ActiveRecord/Rails 4.2, but there are some tests still failing. To see exactly
|
68
|
-
what might not work, check pending specs in Rails 4.2 builds.)
|
63
|
+
- ActiveRecord >= 6.1
|
69
64
|
|
70
65
|
To translate attributes on a model, extend `Mobility`, then call `translates`
|
71
66
|
passing in one or more attributes as well as a hash of options (see below).
|
@@ -109,7 +109,13 @@ columns to that table.
|
|
109
109
|
options[:association_name] = :translations
|
110
110
|
options[:subclass_name] ||= :Translation
|
111
111
|
end
|
112
|
-
%i[foreign_key association_name subclass_name table_name].each { |key|
|
112
|
+
%i[foreign_key association_name subclass_name table_name].each { |key|
|
113
|
+
if options[key].is_a?(Enumerable)
|
114
|
+
options[key] = options[key].map!(&:to_sym)
|
115
|
+
else
|
116
|
+
options[key] = options[key].to_sym
|
117
|
+
end
|
118
|
+
}
|
113
119
|
end
|
114
120
|
# @!endgroup
|
115
121
|
|
@@ -119,6 +119,14 @@ the ActiveRecord dirty plugin for more information.
|
|
119
119
|
class HandlerMethodsBuilder < Module
|
120
120
|
attr_reader :klass
|
121
121
|
|
122
|
+
PATTERNS_WITH_KWARGS =
|
123
|
+
%w[
|
124
|
+
%s_changed?
|
125
|
+
%s_previously_changed?
|
126
|
+
will_save_change_to_%s?
|
127
|
+
saved_change_to_%s?
|
128
|
+
].freeze
|
129
|
+
|
122
130
|
# @param [Class] klass Dirty class to mimic
|
123
131
|
def initialize(klass)
|
124
132
|
@klass = klass
|
@@ -135,7 +143,7 @@ the ActiveRecord dirty plugin for more information.
|
|
135
143
|
public_patterns.each do |pattern|
|
136
144
|
method_name = pattern % 'attribute'
|
137
145
|
|
138
|
-
kwargs = pattern
|
146
|
+
kwargs = PATTERNS_WITH_KWARGS.include?(pattern) ? ', **kwargs' : ''
|
139
147
|
module_eval <<-EOM, __FILE__, __LINE__ + 1
|
140
148
|
def #{method_name}(attr_name, *rest#{kwargs})
|
141
149
|
if (mutations_from_mobility.attribute_changed?(attr_name) ||
|
@@ -298,8 +306,10 @@ the ActiveRecord dirty plugin for more information.
|
|
298
306
|
(OPTION_NOT_GIVEN == to || fetch_value(attr_name) == to)
|
299
307
|
end
|
300
308
|
|
301
|
-
def attribute_previously_changed?(attr_name)
|
302
|
-
previous_changes.include?(attr_name)
|
309
|
+
def attribute_previously_changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
|
310
|
+
previous_changes.include?(attr_name) &&
|
311
|
+
(OPTION_NOT_GIVEN == from || attribute_previous_change(attr_name).first == from) &&
|
312
|
+
(OPTION_NOT_GIVEN == to || attribute_previous_change(attr_name).second == to)
|
303
313
|
end
|
304
314
|
|
305
315
|
def attribute_was(attr_name)
|
data/lib/mobility/version.rb
CHANGED
data/lib/mobility.rb
CHANGED
@@ -90,7 +90,7 @@ module Mobility
|
|
90
90
|
CALL_COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?]?\z/
|
91
91
|
private_constant :CALL_COMPILABLE_REGEXP
|
92
92
|
|
93
|
-
require "rails/generators/mobility/generators" if defined?(Rails)
|
93
|
+
require "rails/generators/mobility/generators" if defined?(Rails) && defined?(ActiveRecord)
|
94
94
|
|
95
95
|
class << self
|
96
96
|
def extended(model_class)
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -12,30 +12,30 @@ cert_chain:
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ4wDAYDVQQDDAVjaHJp
|
14
14
|
czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
|
15
|
-
|
15
|
+
MB4XDTI0MDMzMTA4NTQyOFoXDTI1MDMzMTA4NTQyOFowPzEOMAwGA1UEAwwFY2hy
|
16
16
|
aXMxGDAWBgoJkiaJk/IsZAEZFghkZWppbWF0YTETMBEGCgmSJomT8ixkARkWA2Nv
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
/
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+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cfceZK4BHC4M3pKsV+m7euWMYguz
|
32
|
+
ctOqZgbvGDwFvsH302xC53hld7AaFLBep6XaQZSRleVqgIEKZwlG0cX8UwG482Xt
|
33
|
+
WJSXNylIIbzRndVjbVdGVhhcyjnswfu1qJpl+0YlbAdHJVsd8Ux8TOXEPFMv5wz9
|
34
|
+
wXhTYFvkOuleWf/45E5f8BtT1iqsH2w3P2Cfy+yOo2aReAVSeR12YDCuV0q6RjTD
|
35
|
+
3I5AfnFAG4/1IwhadqwF5cl3jOUa7n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
|
36
|
+
tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2024-03-
|
38
|
+
date: 2024-03-31 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: request_store
|
metadata.gz.sig
CHANGED
Binary file
|