activemodel 7.1.3.1 → 7.1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: beee02cd565e0c451053de59b6cc4c7bb1721054d62afe32c7525cbe713e9fd0
4
- data.tar.gz: 5b7289731c7866960ce141245a69fad063531d5af4d8e9253aca5b3bac74b304
3
+ metadata.gz: 244c56485f6b507cadace603d736b30bcab923144e9a556d3f79add20b790935
4
+ data.tar.gz: 172f280d76e2f60d35db0ccee50ee8f25dbd0c366e3f51e2a3522253c947795d
5
5
  SHA512:
6
- metadata.gz: 6aada1e6282e826135fa2f1f415daf1bab1cba64d0b46abdaf4e55221993450d5a76ce8876bac074bdfd8b8b841ab6b589c48590b258afd9d7c644a7eb7e5a86
7
- data.tar.gz: 8d4f9dfd49c619c01bd9e16837cfc1971cf9a5ac0b73369efe015059a7bedeba4e831cb00540a508d60bb95e64bb7d087c9b20e49ba6b598be60fd7f8574617b
6
+ metadata.gz: 769239956a7f534c54f41e473271c586c8c9c7b190e24e10dbed1c7485dfde885c10afe89ab92f1e6870a04f39f1851691891025bbb77431349e93a97571ed64
7
+ data.tar.gz: 38f5d2bb2659f616791dfe9266725fb56a12fabbcaa8b7e659794ede4812e7fb95a59ac3f702a80e0ebaca0519a484b2a577a52bfece685ff5c1793716af00ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ ## Rails 7.1.4.1 (October 15, 2024) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.1.4 (August 22, 2024) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 7.1.3.4 (June 04, 2024) ##
12
+
13
+ * No changes.
14
+
15
+
16
+ ## Rails 7.1.3.3 (May 16, 2024) ##
17
+
18
+ * No changes.
19
+
20
+
21
+ ## Rails 7.1.3.2 (February 21, 2024) ##
22
+
23
+ * No changes.
24
+
25
+
1
26
  ## Rails 7.1.3.1 (February 21, 2024) ##
2
27
 
3
28
  * No changes.
@@ -215,10 +215,8 @@ module ActiveModel
215
215
  end
216
216
  end
217
217
 
218
- def generate_alias_attribute_methods(code_generator, new_name, old_name)
219
- attribute_method_patterns.each do |pattern|
220
- alias_attribute_method_definition(code_generator, pattern, new_name, old_name)
221
- end
218
+ def generate_alias_attribute_methods(code_generator, new_name, old_name) # :nodoc:
219
+ define_attribute_method(old_name, _owner: code_generator, as: new_name)
222
220
  end
223
221
 
224
222
  def alias_attribute_method_definition(code_generator, pattern, new_name, old_name) # :nodoc:
@@ -231,7 +229,7 @@ module ActiveModel
231
229
  mangled_name = "__temp__#{target_name.unpack1("h*")}"
232
230
  end
233
231
 
234
- code_generator.define_cached_method(method_name, as: mangled_name, namespace: :alias_attribute) do |batch|
232
+ code_generator.define_cached_method(mangled_name, as: method_name, namespace: :alias_attribute) do |batch|
235
233
  body = if CALL_COMPILABLE_REGEXP.match?(target_name)
236
234
  "self.#{target_name}(#{parameters || ''})"
237
235
  else
@@ -321,25 +319,44 @@ module ActiveModel
321
319
  # person.name = 'Bob'
322
320
  # person.name # => "Bob"
323
321
  # person.name_short? # => true
324
- def define_attribute_method(attr_name, _owner: generated_attribute_methods)
322
+ def define_attribute_method(attr_name, _owner: generated_attribute_methods, as: attr_name)
325
323
  ActiveSupport::CodeGenerator.batch(_owner, __FILE__, __LINE__) do |owner|
326
324
  attribute_method_patterns.each do |pattern|
327
- method_name = pattern.method_name(attr_name)
328
-
329
- unless instance_method_already_implemented?(method_name)
330
- generate_method = "define_method_#{pattern.proxy_target}"
331
-
332
- if respond_to?(generate_method, true)
333
- send(generate_method, attr_name.to_s, owner: owner)
334
- else
335
- define_proxy_call(owner, method_name, pattern.proxy_target, pattern.parameters, attr_name.to_s, namespace: :active_model_proxy)
336
- end
337
- end
325
+ define_attribute_method_pattern(pattern, attr_name, owner: owner, as: as)
338
326
  end
339
327
  attribute_method_patterns_cache.clear
340
328
  end
341
329
  end
342
330
 
331
+ def define_attribute_method_pattern(pattern, attr_name, owner:, as:, override: false) # :nodoc:
332
+ canonical_method_name = pattern.method_name(attr_name)
333
+ public_method_name = pattern.method_name(as)
334
+
335
+ # If defining a regular attribute method, we don't override methods that are explictly
336
+ # defined in parrent classes.
337
+ if instance_method_already_implemented?(public_method_name)
338
+ # However, for `alias_attribute`, we always define the method.
339
+ # We check for override second because `instance_method_already_implemented?`
340
+ # also check for dangerous methods.
341
+ return unless override
342
+ end
343
+
344
+ generate_method = "define_method_#{pattern.proxy_target}"
345
+ if respond_to?(generate_method, true)
346
+ send(generate_method, attr_name.to_s, owner: owner, as: as)
347
+ else
348
+ define_proxy_call(
349
+ owner,
350
+ canonical_method_name,
351
+ pattern.proxy_target,
352
+ pattern.parameters,
353
+ attr_name.to_s,
354
+ namespace: :active_model_proxy,
355
+ as: public_method_name,
356
+ )
357
+ end
358
+ end
359
+
343
360
  # Removes all the previously dynamically defined methods from the class, including alias attribute methods.
344
361
  #
345
362
  # class Person
@@ -418,7 +435,7 @@ module ActiveModel
418
435
  # Define a method `name` in `mod` that dispatches to `send`
419
436
  # using the given `extra` args. This falls back on `send`
420
437
  # if the called name cannot be compiled.
421
- def define_proxy_call(code_generator, name, proxy_target, parameters, *call_args, namespace:)
438
+ def define_proxy_call(code_generator, name, proxy_target, parameters, *call_args, namespace:, as: name)
422
439
  mangled_name = name
423
440
  unless NAME_COMPILABLE_REGEXP.match?(name)
424
441
  mangled_name = "__temp__#{name.unpack1("h*")}"
@@ -426,9 +443,9 @@ module ActiveModel
426
443
 
427
444
  call_args.map!(&:inspect)
428
445
  call_args << parameters if parameters
429
- namespace = :"#{namespace}_#{proxy_target}_#{call_args.join("_")}}"
446
+ namespace = :"#{namespace}_#{proxy_target}"
430
447
 
431
- code_generator.define_cached_method(name, as: mangled_name, namespace: namespace) do |batch|
448
+ code_generator.define_cached_method(mangled_name, as: as, namespace: namespace) do |batch|
432
449
  body = if CALL_COMPILABLE_REGEXP.match?(proxy_target)
433
450
  "self.#{proxy_target}(#{call_args.join(", ")})"
434
451
  else
@@ -76,11 +76,11 @@ module ActiveModel
76
76
  end
77
77
 
78
78
  private
79
- def define_method_attribute=(name, owner:)
79
+ def define_method_attribute=(canonical_name, owner:, as: canonical_name)
80
80
  ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
81
- owner, name, writer: true,
81
+ owner, canonical_name, writer: true,
82
82
  ) do |temp_method_name, attr_name_expr|
83
- owner.define_cached_method("#{name}=", as: temp_method_name, namespace: :active_model) do |batch|
83
+ owner.define_cached_method(temp_method_name, as: "#{as}=", namespace: :active_model) do |batch|
84
84
  batch <<
85
85
  "def #{temp_method_name}(value)" <<
86
86
  " _write_attribute(#{attr_name_expr}, value)" <<
@@ -9,7 +9,7 @@ module ActiveModel
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 1
12
- TINY = 3
12
+ TINY = 4
13
13
  PRE = "1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
data/lib/active_model.rb CHANGED
@@ -28,7 +28,7 @@ require "active_support/rails"
28
28
  require "active_model/version"
29
29
  require "active_model/deprecator"
30
30
 
31
- # :include: activemodel/README.rdoc
31
+ # :include: ../README.rdoc
32
32
  module ActiveModel
33
33
  extend ActiveSupport::Autoload
34
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.3.1
4
+ version: 7.1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 7.1.3.1
19
+ version: 7.1.4.1
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: 7.1.3.1
26
+ version: 7.1.4.1
27
27
  description: A toolkit for building modeling frameworks like Active Record. Rich support
28
28
  for attributes, callbacks, validations, serialization, internationalization, and
29
29
  testing.
@@ -112,12 +112,12 @@ licenses:
112
112
  - MIT
113
113
  metadata:
114
114
  bug_tracker_uri: https://github.com/rails/rails/issues
115
- changelog_uri: https://github.com/rails/rails/blob/v7.1.3.1/activemodel/CHANGELOG.md
116
- documentation_uri: https://api.rubyonrails.org/v7.1.3.1/
115
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.4.1/activemodel/CHANGELOG.md
116
+ documentation_uri: https://api.rubyonrails.org/v7.1.4.1/
117
117
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
118
- source_code_uri: https://github.com/rails/rails/tree/v7.1.3.1/activemodel
118
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.4.1/activemodel
119
119
  rubygems_mfa_required: 'true'
120
- post_install_message:
120
+ post_install_message:
121
121
  rdoc_options: []
122
122
  require_paths:
123
123
  - lib
@@ -132,8 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.4.10
136
- signing_key:
135
+ rubygems_version: 3.5.16
136
+ signing_key:
137
137
  specification_version: 4
138
138
  summary: A toolkit for building modeling frameworks (part of Rails).
139
139
  test_files: []