mobility 0.8.13 → 1.0.0

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.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -2
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG.md +63 -0
  5. data/Gemfile +5 -2
  6. data/Gemfile.lock +39 -20
  7. data/README.md +183 -93
  8. data/lib/mobility.rb +101 -169
  9. data/lib/mobility/backend.rb +27 -51
  10. data/lib/mobility/backends.rb +20 -0
  11. data/lib/mobility/backends/active_record.rb +4 -0
  12. data/lib/mobility/backends/active_record/column.rb +3 -1
  13. data/lib/mobility/backends/active_record/container.rb +10 -11
  14. data/lib/mobility/backends/active_record/hstore.rb +6 -4
  15. data/lib/mobility/backends/active_record/json.rb +5 -3
  16. data/lib/mobility/backends/active_record/jsonb.rb +5 -3
  17. data/lib/mobility/backends/active_record/key_value.rb +31 -13
  18. data/lib/mobility/backends/active_record/pg_hash.rb +1 -1
  19. data/lib/mobility/backends/active_record/serialized.rb +6 -0
  20. data/lib/mobility/backends/active_record/table.rb +17 -10
  21. data/lib/mobility/backends/column.rb +0 -6
  22. data/lib/mobility/backends/container.rb +10 -1
  23. data/lib/mobility/backends/hash.rb +39 -0
  24. data/lib/mobility/backends/hash_valued.rb +4 -0
  25. data/lib/mobility/backends/hstore.rb +0 -1
  26. data/lib/mobility/backends/json.rb +0 -1
  27. data/lib/mobility/backends/jsonb.rb +1 -2
  28. data/lib/mobility/backends/key_value.rb +31 -26
  29. data/lib/mobility/backends/null.rb +2 -0
  30. data/lib/mobility/backends/sequel.rb +37 -2
  31. data/lib/mobility/backends/sequel/column.rb +2 -0
  32. data/lib/mobility/backends/sequel/container.rb +11 -9
  33. data/lib/mobility/backends/sequel/hstore.rb +3 -1
  34. data/lib/mobility/backends/sequel/json.rb +3 -0
  35. data/lib/mobility/backends/sequel/jsonb.rb +3 -1
  36. data/lib/mobility/backends/sequel/key_value.rb +87 -18
  37. data/lib/mobility/backends/sequel/pg_hash.rb +6 -6
  38. data/lib/mobility/backends/sequel/serialized.rb +6 -0
  39. data/lib/mobility/backends/sequel/table.rb +22 -9
  40. data/lib/mobility/backends/serialized.rb +1 -3
  41. data/lib/mobility/backends/table.rb +39 -31
  42. data/lib/mobility/pluggable.rb +56 -0
  43. data/lib/mobility/plugin.rb +260 -0
  44. data/lib/mobility/plugins.rb +27 -24
  45. data/lib/mobility/plugins/active_model.rb +17 -0
  46. data/lib/mobility/plugins/active_model/cache.rb +26 -0
  47. data/lib/mobility/plugins/active_model/dirty.rb +119 -78
  48. data/lib/mobility/plugins/active_record.rb +37 -0
  49. data/lib/mobility/plugins/active_record/backend.rb +27 -0
  50. data/lib/mobility/plugins/active_record/cache.rb +28 -0
  51. data/lib/mobility/plugins/active_record/dirty.rb +34 -17
  52. data/lib/mobility/plugins/active_record/query.rb +43 -31
  53. data/lib/mobility/plugins/active_record/uniqueness_validation.rb +64 -0
  54. data/lib/mobility/plugins/arel.rb +125 -0
  55. data/lib/mobility/plugins/arel/nodes.rb +15 -0
  56. data/lib/mobility/plugins/arel/nodes/pg_ops.rb +134 -0
  57. data/lib/mobility/plugins/attribute_methods.rb +29 -20
  58. data/lib/mobility/plugins/attributes.rb +72 -0
  59. data/lib/mobility/plugins/backend.rb +161 -0
  60. data/lib/mobility/plugins/backend_reader.rb +34 -0
  61. data/lib/mobility/plugins/cache.rb +68 -26
  62. data/lib/mobility/plugins/default.rb +22 -17
  63. data/lib/mobility/plugins/dirty.rb +12 -33
  64. data/lib/mobility/plugins/fallbacks.rb +52 -44
  65. data/lib/mobility/plugins/fallthrough_accessors.rb +19 -23
  66. data/lib/mobility/plugins/locale_accessors.rb +22 -35
  67. data/lib/mobility/plugins/presence.rb +28 -21
  68. data/lib/mobility/plugins/query.rb +8 -17
  69. data/lib/mobility/plugins/reader.rb +50 -0
  70. data/lib/mobility/plugins/sequel.rb +34 -0
  71. data/lib/mobility/plugins/sequel/backend.rb +25 -0
  72. data/lib/mobility/plugins/sequel/cache.rb +24 -0
  73. data/lib/mobility/plugins/sequel/dirty.rb +34 -23
  74. data/lib/mobility/plugins/sequel/query.rb +21 -6
  75. data/lib/mobility/plugins/writer.rb +44 -0
  76. data/lib/mobility/translations.rb +95 -0
  77. data/lib/mobility/version.rb +12 -1
  78. data/lib/rails/generators/mobility/templates/create_string_translations.rb +0 -1
  79. data/lib/rails/generators/mobility/templates/create_text_translations.rb +0 -1
  80. data/lib/rails/generators/mobility/templates/initializer.rb +104 -78
  81. metadata +35 -40
  82. metadata.gz.sig +0 -0
  83. data/lib/mobility/active_model.rb +0 -4
  84. data/lib/mobility/active_model/backend_resetter.rb +0 -26
  85. data/lib/mobility/active_record.rb +0 -23
  86. data/lib/mobility/active_record/backend_resetter.rb +0 -26
  87. data/lib/mobility/active_record/model_translation.rb +0 -14
  88. data/lib/mobility/active_record/string_translation.rb +0 -10
  89. data/lib/mobility/active_record/text_translation.rb +0 -10
  90. data/lib/mobility/active_record/translation.rb +0 -14
  91. data/lib/mobility/active_record/uniqueness_validator.rb +0 -60
  92. data/lib/mobility/arel.rb +0 -49
  93. data/lib/mobility/arel/nodes.rb +0 -13
  94. data/lib/mobility/arel/nodes/pg_ops.rb +0 -132
  95. data/lib/mobility/arel/visitor.rb +0 -61
  96. data/lib/mobility/attributes.rb +0 -324
  97. data/lib/mobility/backend/orm_delegator.rb +0 -44
  98. data/lib/mobility/backend_resetter.rb +0 -50
  99. data/lib/mobility/configuration.rb +0 -138
  100. data/lib/mobility/fallbacks.rb +0 -28
  101. data/lib/mobility/interface.rb +0 -0
  102. data/lib/mobility/loaded.rb +0 -4
  103. data/lib/mobility/plugins/active_record/attribute_methods.rb +0 -38
  104. data/lib/mobility/plugins/cache/translation_cacher.rb +0 -40
  105. data/lib/mobility/sequel.rb +0 -9
  106. data/lib/mobility/sequel/backend_resetter.rb +0 -23
  107. data/lib/mobility/sequel/column_changes.rb +0 -28
  108. data/lib/mobility/sequel/hash_initializer.rb +0 -21
  109. data/lib/mobility/sequel/model_translation.rb +0 -20
  110. data/lib/mobility/sequel/sql.rb +0 -16
  111. data/lib/mobility/sequel/string_translation.rb +0 -10
  112. data/lib/mobility/sequel/text_translation.rb +0 -10
  113. data/lib/mobility/sequel/translation.rb +0 -53
  114. data/lib/mobility/translates.rb +0 -73
@@ -1,5 +1,4 @@
1
1
  class CreateStringTranslations < <%= activerecord_migration_class %>
2
-
3
2
  def change
4
3
  create_table :mobility_string_translations do |t|
5
4
  t.string :locale, null: false
@@ -1,5 +1,4 @@
1
1
  class CreateTextTranslations < <%= activerecord_migration_class %>
2
-
3
2
  def change
4
3
  create_table :mobility_text_translations do |t|
5
4
  t.string :locale, null: false
@@ -1,90 +1,116 @@
1
- Mobility.configure do |config|
2
- # Sets the default backend to use in models. This can be overridden in models
3
- # by passing +backend: ...+ to +translates+.
4
- config.default_backend = :key_value
1
+ Mobility.configure do
2
+ # PLUGINS
3
+ plugins do
4
+ # Backend
5
+ #
6
+ # Sets the default backend to use in models. This can be overridden in models
7
+ # by passing +backend: ...+ to +translates+.
8
+ #
9
+ # To default to a different backend globally, replace +:key_value+ by another
10
+ # backend name.
11
+ #
12
+ backend :key_value
5
13
 
6
- # By default, Mobility uses the +translates+ class method in models to
7
- # describe translated attributes, but you can configure this method to be
8
- # whatever you like. This may be useful if using Mobility alongside another
9
- # translation gem which uses the same method name.
10
- config.accessor_method = :translates
14
+ # ActiveRecord
15
+ #
16
+ # Defines ActiveRecord as ORM, and enables ActiveRecord-specific plugins.
17
+ active_record
11
18
 
12
- # To query on translated attributes, you need to append a scope to your
13
- # model. The name of this scope is +i18n+ by default, but this can be changed
14
- # to something else.
15
- config.query_method = :i18n
19
+ # Accessors
20
+ #
21
+ # Define reader and writer methods for translated attributes. Remove either
22
+ # to disable globally, or pass +reader: false+ or +writer: false+ to
23
+ # +translates+ in any translated model.
24
+ #
25
+ reader
26
+ writer
16
27
 
17
- # Uncomment and remove (or add) items to (from) this list to completely
18
- # disable/enable plugins globally (so they cannot be used and are never even
19
- # loaded). Note that if you remove an item from the list, you will not be
20
- # able to use the plugin at all, and any options for the plugin will be
21
- # ignored by models. (In most cases, you probably don't want to change this.)
22
- #
23
- # config.plugins = %i[
24
- # query
25
- # cache
26
- # dirty
27
- # fallbacks
28
- # presence
29
- # default
30
- # attribute_methods
31
- # fallthrough_accessors
32
- # locale_accessors
33
- # ]
28
+ # Backend Reader
29
+ #
30
+ # Defines reader to access the backend for any attribute, of the form
31
+ # +<attribute>_backend+.
32
+ #
33
+ backend_reader
34
+ #
35
+ # Or pass an interpolation string to define a different pattern:
36
+ # backend_reader "%s_translations"
34
37
 
35
- # The translation cache is on by default, but you can turn it off by
36
- # uncommenting this line. (This may be helpful in debugging.)
37
- #
38
- # config.default_options[:cache] = false
38
+ # Query
39
+ #
40
+ # Defines a scope on the model class which allows querying on
41
+ # translated attributes. The default scope is named +i18n+, pass a different
42
+ # name as default to change the global default, or to +translates+ in any
43
+ # model to change it for that model alone.
44
+ #
45
+ query
39
46
 
40
- # Dirty tracking is disabled by default. Uncomment this line to enable it.
41
- # If you enable this, you should also enable +locale_accessors+ by default
42
- # (see below).
43
- #
44
- # config.default_options[:dirty] = true
47
+ # Cache
48
+ #
49
+ # Comment out to disable caching reads and writes.
50
+ #
51
+ cache
45
52
 
46
- # No fallbacks are used by default. To define default fallbacks, uncomment
47
- # and set the default fallback option value here. A "true" value will use
48
- # whatever is defined by +I18n.fallbacks+ (if defined), or alternatively will
49
- # fallback to your +I18n.default_locale+.
50
- #
51
- # config.default_options[:fallbacks] = true
53
+ # Dirty
54
+ #
55
+ # Uncomment this line to include and enable globally:
56
+ # dirty
57
+ #
58
+ # Or uncomment this line to include but disable by default, and only enable
59
+ # per model by passing +dirty: true+ to +translates+.
60
+ # dirty false
52
61
 
53
- # The Presence plugin converts empty strings to nil when fetching and setting
54
- # translations. By default it is on, uncomment this line to turn it off.
55
- #
56
- # config.default_options[:presence] = false
62
+ # Fallbacks
63
+ #
64
+ # Uncomment line below to enable fallbacks, using +I18n.fallbacks+.
65
+ # fallbacks
66
+ #
67
+ # Or uncomment this line to enable fallbacks with a global default.
68
+ # fallbacks { :pt => :en }
57
69
 
58
- # Set a default value to use if the translation is nil. By default this is
59
- # off, uncomment and set a default to use it across all models (you probably
60
- # don't want to do that).
61
- #
62
- # config.default_options[:default] = ...
70
+ # Presence
71
+ #
72
+ # Converts blank strings to nil on reads and writes. Comment out to
73
+ # disable.
74
+ #
75
+ presence
63
76
 
64
- # Uncomment to enable locale_accessors by default on models. A true value
65
- # will use the locales defined either in
66
- # Rails.application.config.i18n.available_locales or I18n.available_locales.
67
- # If you want something else, pass an array of locales instead.
68
- #
69
- # config.default_options[:locale_accessors] = true
77
+ # Default
78
+ #
79
+ # Set a default translation per attributes. When enabled, passing +default:
80
+ # 'foo'+ sets a default translation string to show in case no translation is
81
+ # present. Can also be passed a proc.
82
+ #
83
+ # default 'foo'
70
84
 
71
- # Uncomment to enable fallthrough accessors by default on models. This will
72
- # allow you to call any method with a suffix like _en or _pt_br, and Mobility
73
- # will catch the suffix and convert it into a locale in +method_missing+. If
74
- # you don't need this kind of open-ended fallthrough behavior, it's better
75
- # to use locale_accessors instead (which define methods) since method_missing
76
- # is very slow. (You can use both fallthrough and locale accessor plugins
77
- # together without conflict.)
78
- #
79
- # Note: The dirty plugin enables fallthrough_accessors by default.
80
- #
81
- # config.default_options[:fallthrough_accessors] = true
85
+ # Fallthrough Accessors
86
+ #
87
+ # Uses method_missing to define locale-specific accessor methods like
88
+ # +title_en+, +title_en=+, +title_fr+, +title_fr=+ for each translated
89
+ # attribute. If you know what set of locales you want to support, it's
90
+ # generally better to use Locale Accessors (or both together) since
91
+ # +method_missing+ is very slow. (You can use both fallthrough and locale
92
+ # accessor plugins together without conflict.)
93
+ #
94
+ # fallthrough_accessors
82
95
 
83
- # You can also include backend-specific default options. For example, if you
84
- # want to default to using the text-type translation table with the KeyValue
85
- # backend, you can set that as a default by uncommenting this line, or change
86
- # it to :string to default to the string-type translation table instead. (For
87
- # other backends, this option is ignored.)
88
- #
89
- # config.default_options[:type] = :text
96
+ # Locale Accessors
97
+ #
98
+ # Uses +def+ to define accessor methods for a set of locales. By default uses
99
+ # +I18n.available_locales+, but you can pass the set of locales with
100
+ # +translates+ and/or set a global default here.
101
+ #
102
+ # locale_accessors
103
+ #
104
+ # Or define specific defaults by uncommenting line below
105
+ # locale_accessors [:en, :ja]
106
+
107
+ # Attribute Methods
108
+ #
109
+ # Adds translated attributes to +attributes+ hash, and defines methods
110
+ # +translated_attributes+ and +untranslated_attributes+ which return hashes
111
+ # with translatd and untranslated attributes, respectively. Be aware that
112
+ # this plugin can create conflicts with other gems.
113
+ #
114
+ # attribute_methods
115
+ end
90
116
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.13
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain:
11
11
  - |
@@ -34,7 +34,7 @@ cert_chain:
34
34
  gSQml7TqcC6dZRsZRwYqzD9kUwdAJoCqno2CBUKs2l0yQAjFT36lRrVJznb7uWwa
35
35
  xpPFnsrtyaZW6Dty8TSG3qzmeGpmpIotA8x1VA==
36
36
  -----END CERTIFICATE-----
37
- date: 2020-05-27 00:00:00.000000000 Z
37
+ date: 2020-12-12 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: request_store
@@ -156,23 +156,7 @@ files:
156
156
  - README.md
157
157
  - Rakefile
158
158
  - lib/mobility.rb
159
- - lib/mobility/active_model.rb
160
- - lib/mobility/active_model/backend_resetter.rb
161
- - lib/mobility/active_record.rb
162
- - lib/mobility/active_record/backend_resetter.rb
163
- - lib/mobility/active_record/model_translation.rb
164
- - lib/mobility/active_record/string_translation.rb
165
- - lib/mobility/active_record/text_translation.rb
166
- - lib/mobility/active_record/translation.rb
167
- - lib/mobility/active_record/uniqueness_validator.rb
168
- - lib/mobility/arel.rb
169
- - lib/mobility/arel/nodes.rb
170
- - lib/mobility/arel/nodes/pg_ops.rb
171
- - lib/mobility/arel/visitor.rb
172
- - lib/mobility/attributes.rb
173
159
  - lib/mobility/backend.rb
174
- - lib/mobility/backend/orm_delegator.rb
175
- - lib/mobility/backend_resetter.rb
176
160
  - lib/mobility/backends.rb
177
161
  - lib/mobility/backends/active_record.rb
178
162
  - lib/mobility/backends/active_record/column.rb
@@ -186,6 +170,7 @@ files:
186
170
  - lib/mobility/backends/active_record/table.rb
187
171
  - lib/mobility/backends/column.rb
188
172
  - lib/mobility/backends/container.rb
173
+ - lib/mobility/backends/hash.rb
189
174
  - lib/mobility/backends/hash_valued.rb
190
175
  - lib/mobility/backends/hstore.rb
191
176
  - lib/mobility/backends/json.rb
@@ -204,20 +189,26 @@ files:
204
189
  - lib/mobility/backends/sequel/table.rb
205
190
  - lib/mobility/backends/serialized.rb
206
191
  - lib/mobility/backends/table.rb
207
- - lib/mobility/configuration.rb
208
- - lib/mobility/fallbacks.rb
209
- - lib/mobility/interface.rb
210
- - lib/mobility/loaded.rb
192
+ - lib/mobility/pluggable.rb
193
+ - lib/mobility/plugin.rb
211
194
  - lib/mobility/plugins.rb
212
195
  - lib/mobility/plugins/active_model.rb
196
+ - lib/mobility/plugins/active_model/cache.rb
213
197
  - lib/mobility/plugins/active_model/dirty.rb
214
198
  - lib/mobility/plugins/active_record.rb
215
- - lib/mobility/plugins/active_record/attribute_methods.rb
199
+ - lib/mobility/plugins/active_record/backend.rb
200
+ - lib/mobility/plugins/active_record/cache.rb
216
201
  - lib/mobility/plugins/active_record/dirty.rb
217
202
  - lib/mobility/plugins/active_record/query.rb
203
+ - lib/mobility/plugins/active_record/uniqueness_validation.rb
204
+ - lib/mobility/plugins/arel.rb
205
+ - lib/mobility/plugins/arel/nodes.rb
206
+ - lib/mobility/plugins/arel/nodes/pg_ops.rb
218
207
  - lib/mobility/plugins/attribute_methods.rb
208
+ - lib/mobility/plugins/attributes.rb
209
+ - lib/mobility/plugins/backend.rb
210
+ - lib/mobility/plugins/backend_reader.rb
219
211
  - lib/mobility/plugins/cache.rb
220
- - lib/mobility/plugins/cache/translation_cacher.rb
221
212
  - lib/mobility/plugins/default.rb
222
213
  - lib/mobility/plugins/dirty.rb
223
214
  - lib/mobility/plugins/fallbacks.rb
@@ -225,19 +216,14 @@ files:
225
216
  - lib/mobility/plugins/locale_accessors.rb
226
217
  - lib/mobility/plugins/presence.rb
227
218
  - lib/mobility/plugins/query.rb
219
+ - lib/mobility/plugins/reader.rb
228
220
  - lib/mobility/plugins/sequel.rb
221
+ - lib/mobility/plugins/sequel/backend.rb
222
+ - lib/mobility/plugins/sequel/cache.rb
229
223
  - lib/mobility/plugins/sequel/dirty.rb
230
224
  - lib/mobility/plugins/sequel/query.rb
231
- - lib/mobility/sequel.rb
232
- - lib/mobility/sequel/backend_resetter.rb
233
- - lib/mobility/sequel/column_changes.rb
234
- - lib/mobility/sequel/hash_initializer.rb
235
- - lib/mobility/sequel/model_translation.rb
236
- - lib/mobility/sequel/sql.rb
237
- - lib/mobility/sequel/string_translation.rb
238
- - lib/mobility/sequel/text_translation.rb
239
- - lib/mobility/sequel/translation.rb
240
- - lib/mobility/translates.rb
225
+ - lib/mobility/plugins/writer.rb
226
+ - lib/mobility/translations.rb
241
227
  - lib/mobility/util.rb
242
228
  - lib/mobility/version.rb
243
229
  - lib/rails/generators/mobility/active_record_migration_compatibility.rb
@@ -257,8 +243,17 @@ files:
257
243
  homepage: https://github.com/shioyama/mobility
258
244
  licenses:
259
245
  - MIT
260
- metadata: {}
261
- post_install_message:
246
+ metadata:
247
+ homepage_uri: https://github.com/shioyama/mobility
248
+ source_code_uri: https://github.com/shioyama/mobility
249
+ changelog_uri: https://github.com/shioyama/mobility/blob/master/CHANGELOG.md
250
+ post_install_message: |2
251
+
252
+ Warning: Mobility v1.0 includes backwards-incompatible changes (mostly around configuration).
253
+
254
+ If you are upgrading from an earlier version, please see:
255
+ - https://github.com/shioyama/mobility/releases/tag/v1.0.0
256
+ - https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0
262
257
  rdoc_options: []
263
258
  require_paths:
264
259
  - lib
@@ -266,15 +261,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
261
  requirements:
267
262
  - - ">="
268
263
  - !ruby/object:Gem::Version
269
- version: 2.3.7
264
+ version: '2.5'
270
265
  required_rubygems_version: !ruby/object:Gem::Requirement
271
266
  requirements:
272
267
  - - ">="
273
268
  - !ruby/object:Gem::Version
274
269
  version: '0'
275
270
  requirements: []
276
- rubygems_version: 3.0.3
277
- signing_key:
271
+ rubygems_version: 3.1.2
272
+ signing_key:
278
273
  specification_version: 4
279
274
  summary: Pluggable Ruby translation framework
280
275
  test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,4 +0,0 @@
1
- module Mobility
2
- module ActiveModel
3
- end
4
- end
@@ -1,26 +0,0 @@
1
- module Mobility
2
- module ActiveModel
3
- =begin
4
-
5
- Backend resetter for ActiveModel models. Adds hook to reset backend when
6
- +changes_applied+ or +clear_changes_information+ methods are called on model.
7
-
8
- =end
9
- class BackendResetter < Mobility::BackendResetter
10
-
11
- # (see Mobility::BackendResetter#initialize)
12
- def initialize(attribute_names, &block)
13
- super
14
-
15
- model_reset_method = @model_reset_method
16
-
17
- %i[changes_applied clear_changes_information].each do |method|
18
- define_method method do
19
- super()
20
- instance_eval(&model_reset_method)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
- require "mobility/arel"
3
-
4
- module Mobility
5
- =begin
6
-
7
- Module loading ActiveRecord-specific classes for Mobility models.
8
-
9
- =end
10
- module ActiveRecord
11
- require "mobility/active_record/uniqueness_validator"
12
-
13
- def self.included(model_class)
14
- model_class.class_eval do
15
- unless const_defined?(:UniquenessValidator)
16
- const_set(:UniquenessValidator,
17
- Class.new(::Mobility::ActiveRecord::UniquenessValidator))
18
- end
19
- delegate :translated_attribute_names, to: :class
20
- end
21
- end
22
- end
23
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
- require "mobility/active_model/backend_resetter"
3
-
4
- module Mobility
5
- module ActiveRecord
6
- =begin
7
-
8
- Backend resetter for ActiveRecord models. Adds hook on +reload+ event to
9
- {Mobility::ActiveModel::BackendResetter}.
10
-
11
- =end
12
- class BackendResetter < Mobility::ActiveModel::BackendResetter
13
-
14
- # (see Mobility::BackendResetter#initialize)
15
- def initialize(attribute_names, &block)
16
- super
17
-
18
- model_reset_method = @model_reset_method
19
-
20
- define_method :reload do |*args|
21
- super(*args).tap { instance_eval(&model_reset_method) }
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- module Mobility
2
- module ActiveRecord
3
- =begin
4
-
5
- Subclassed dynamically to generate translation class in
6
- {Backends::ActiveRecord::Table} backend.
7
-
8
- =end
9
- class ModelTranslation < ::ActiveRecord::Base
10
- self.abstract_class = true
11
- validates :locale, presence: true
12
- end
13
- end
14
- end