mobility 1.0.0.beta1 → 1.0.0.beta2
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.tar.gz.sig +0 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -3
- data/README.md +1 -1
- data/lib/mobility/plugins/attribute_methods.rb +1 -0
- data/lib/mobility/plugins/attributes.rb +17 -15
- data/lib/mobility/plugins/backend.rb +7 -7
- data/lib/mobility/version.rb +1 -1
- metadata +2 -2
- 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: 2346e4ef46985b520c5feea3577a6644f213e1fe89e3dfd5960f3347c72a1134
|
4
|
+
data.tar.gz: df38726f94dca7139a3eb9cf838b27dfede5378c34290a5298e7dcde01bf3c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236ad0894645f98bf2a21c6848b4ba439da84b24862a56f6fca878889a6cd9a79108711923961d2f9ee75b6a6ee8482fcefff213b5433736fa507332db0cc253
|
7
|
+
data.tar.gz: a3e78f97d08d26e18ac8187b961097e686c3fc5650f45ae84fb4aa1aad1ccd0970410f2b9e887d8618ed6c1a09e559b1fe3fd0428df591de011961a0c2da1379
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@
|
|
4
4
|
|
5
5
|
1.0 is a rewrite of many internals of the gem. Please see the [wiki page on v1.0](https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0) for more details on how to upgrade.
|
6
6
|
|
7
|
+
## 1.0.0.beta2 (pre-release)
|
8
|
+
|
9
|
+
- Refactor attributes & backend plugins and make `mobility_attributes` public
|
10
|
+
([#462](https://github.com/shioyama/mobility/pull/462))
|
11
|
+
- Make attribute_methods plugin depend on attributes
|
12
|
+
([#461](https://github.com/shioyama/mobility/pull/461))
|
13
|
+
|
7
14
|
## 1.0.0.beta1 (pre-release)
|
8
15
|
|
9
16
|
- Remove `Mobility::Backend#apply_plugin`
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mobility (1.0.0.
|
4
|
+
mobility (1.0.0.beta2)
|
5
5
|
i18n (>= 0.6.10, < 2)
|
6
6
|
request_store (~> 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
allocation_stats (0.1.5)
|
12
11
|
benchmark-ips (2.8.3)
|
13
12
|
byebug (11.1.3)
|
14
13
|
coderay (1.1.3)
|
@@ -76,7 +75,6 @@ PLATFORMS
|
|
76
75
|
ruby
|
77
76
|
|
78
77
|
DEPENDENCIES
|
79
|
-
allocation_stats
|
80
78
|
benchmark-ips
|
81
79
|
database_cleaner (~> 1.5, >= 1.5.3)
|
82
80
|
guard-rspec
|
data/README.md
CHANGED
@@ -32,8 +32,15 @@ for aggregating attributes.
|
|
32
32
|
end
|
33
33
|
|
34
34
|
included_hook do |klass|
|
35
|
-
|
36
|
-
|
35
|
+
names = @names
|
36
|
+
|
37
|
+
klass.class_eval do
|
38
|
+
extend ClassMethods
|
39
|
+
names.each { |name| mobility_attributes << name.to_s }
|
40
|
+
mobility_attributes.uniq!
|
41
|
+
rescue FrozenError
|
42
|
+
raise FrozenAttributesError, "Attempting to translate these attributes on #{klass}, which has already been subclassed: #{names.join(', ')}."
|
43
|
+
end
|
37
44
|
end
|
38
45
|
|
39
46
|
module ClassMethods
|
@@ -44,25 +51,20 @@ for aggregating attributes.
|
|
44
51
|
mobility_attributes.include?(name.to_s)
|
45
52
|
end
|
46
53
|
|
47
|
-
# Register a new attribute name. Public, but treat as internal.
|
48
|
-
# @param [String, Symbol] Attribute name
|
49
|
-
def register_mobility_attribute(name)
|
50
|
-
(self.mobility_attributes << name.to_s).uniq!
|
51
|
-
end
|
52
|
-
|
53
|
-
def inherited(klass)
|
54
|
-
super
|
55
|
-
mobility_attributes.each { |name| klass.register_mobility_attribute(name) }
|
56
|
-
end
|
57
|
-
|
58
|
-
protected
|
59
|
-
|
60
54
|
# Return translated attribute names on this model.
|
61
55
|
# @return [Array<String>] Attribute names
|
62
56
|
def mobility_attributes
|
63
57
|
@mobility_attributes ||= []
|
64
58
|
end
|
59
|
+
|
60
|
+
def inherited(klass)
|
61
|
+
super
|
62
|
+
attrs = mobility_attributes.freeze # ensure attributes are not modified after being inherited
|
63
|
+
klass.class_eval { @mobility_attributes = attrs.dup }
|
64
|
+
end
|
65
65
|
end
|
66
|
+
|
67
|
+
class FrozenAttributesError < Error; end
|
66
68
|
end
|
67
69
|
|
68
70
|
register_plugin(:attributes, Attributes)
|
@@ -56,8 +56,11 @@ Defines:
|
|
56
56
|
|
57
57
|
backend_class.setup_model(klass, names)
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
names = @names
|
60
|
+
backend_class = @backend_class
|
61
|
+
|
62
|
+
klass.class_eval do
|
63
|
+
names.each { |name| mobility_backend_classes[name.to_sym] = backend_class }
|
61
64
|
end
|
62
65
|
|
63
66
|
backend_class
|
@@ -137,12 +140,9 @@ Defines:
|
|
137
140
|
raise KeyError, "No backend for: #{name}"
|
138
141
|
end
|
139
142
|
|
140
|
-
def register_mobility_backend_class(name, backend_class)
|
141
|
-
mobility_backend_classes[name.to_sym] = backend_class
|
142
|
-
end
|
143
|
-
|
144
143
|
def inherited(klass)
|
145
|
-
|
144
|
+
parent_classes = mobility_backend_classes.freeze # ensure backend classes are not modified after being inherited
|
145
|
+
klass.class_eval { @mobility_backend_classes = parent_classes.dup }
|
146
146
|
super
|
147
147
|
end
|
148
148
|
|
data/lib/mobility/version.rb
CHANGED
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.0.0.
|
4
|
+
version: 1.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
gSQml7TqcC6dZRsZRwYqzD9kUwdAJoCqno2CBUKs2l0yQAjFT36lRrVJznb7uWwa
|
35
35
|
xpPFnsrtyaZW6Dty8TSG3qzmeGpmpIotA8x1VA==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2020-11-
|
37
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: request_store
|
metadata.gz.sig
CHANGED
Binary file
|