activemodel 7.0.4.3 → 7.0.5

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: b583349040c22994e3416137601ab463e571ce4bf061cfa2bcdee0ff483c1991
4
- data.tar.gz: 9981ebe3f9b0a05eca705de63770ea323e1aa91a5b0af33dcaa7318ec78f36a1
3
+ metadata.gz: b1e260ee8a07b5c46bd04d84013855604516f92bd9d2305cd4108582963551e6
4
+ data.tar.gz: '030858442b97869a031487982dbd29c709af654e01e0e63df48b6b95e20f900a'
5
5
  SHA512:
6
- metadata.gz: f5b6c01c98ad1a60dd2bfba39347b1e4fc015a1cfb89f13d5187bece1e204b7a81da0521dde8e523706fdd5e47b56507a9c9e31f5a3238d41ebffecf537e3af2
7
- data.tar.gz: 1ba1e833a22135483c8d21b494e2a6ba28e9d433e7b6a4bfbedf7e49b3fe99bf6e6e53409292a04319ca6df3996fd1ea7a384a3e53fa569aeab11df1a8cbfb89
6
+ metadata.gz: fef75f5d7769575131c5409a80bc17b955b43e2695f3d6425a47f99a363c49a7991f2d5ab4d7eea8908f45e2af8033ce59cf6bd163c5c9193f345040aed9f646
7
+ data.tar.gz: c1f480b1de01351da6701d5cd5452837de8a44ab01f7d5f196eaab5cb5a76b6bda7666cb4c8a79fa37743f087157431a71b2b9cd63e4609d4475c19d11d4d23f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Rails 7.0.5 (May 24, 2023) ##
2
+
3
+ * No changes.
4
+
5
+
1
6
  ## Rails 7.0.4.3 (March 13, 2023) ##
2
7
 
3
8
  * No changes.
@@ -49,18 +49,17 @@ module ActiveModel
49
49
  # end
50
50
  #
51
51
  # private
52
+ # def attribute_contrived?(attr)
53
+ # true
54
+ # end
52
55
  #
53
- # def attribute_contrived?(attr)
54
- # true
55
- # end
56
- #
57
- # def clear_attribute(attr)
58
- # send("#{attr}=", nil)
59
- # end
56
+ # def clear_attribute(attr)
57
+ # send("#{attr}=", nil)
58
+ # end
60
59
  #
61
- # def reset_attribute_to_default!(attr)
62
- # send("#{attr}=", 'Default Name')
63
- # end
60
+ # def reset_attribute_to_default!(attr)
61
+ # send("#{attr}=", 'Default Name')
62
+ # end
64
63
  # end
65
64
  module AttributeMethods
66
65
  extend ActiveSupport::Concern
@@ -95,10 +94,9 @@ module ActiveModel
95
94
  # define_attribute_methods :name
96
95
  #
97
96
  # private
98
- #
99
- # def clear_attribute(attr)
100
- # send("#{attr}=", nil)
101
- # end
97
+ # def clear_attribute(attr)
98
+ # send("#{attr}=", nil)
99
+ # end
102
100
  # end
103
101
  #
104
102
  # person = Person.new
@@ -131,10 +129,9 @@ module ActiveModel
131
129
  # define_attribute_methods :name
132
130
  #
133
131
  # private
134
- #
135
- # def attribute_short?(attr)
136
- # send(attr).length < 5
137
- # end
132
+ # def attribute_short?(attr)
133
+ # send(attr).length < 5
134
+ # end
138
135
  # end
139
136
  #
140
137
  # person = Person.new
@@ -167,10 +164,9 @@ module ActiveModel
167
164
  # define_attribute_methods :name
168
165
  #
169
166
  # private
170
- #
171
- # def reset_attribute_to_default!(attr)
172
- # send("#{attr}=", 'Default Name')
173
- # end
167
+ # def reset_attribute_to_default!(attr)
168
+ # send("#{attr}=", 'Default Name')
169
+ # end
174
170
  # end
175
171
  #
176
172
  # person = Person.new
@@ -194,10 +190,9 @@ module ActiveModel
194
190
  # alias_attribute :nickname, :name
195
191
  #
196
192
  # private
197
- #
198
- # def attribute_short?(attr)
199
- # send(attr).length < 5
200
- # end
193
+ # def attribute_short?(attr)
194
+ # send(attr).length < 5
195
+ # end
201
196
  # end
202
197
  #
203
198
  # person = Person.new
@@ -268,10 +263,9 @@ module ActiveModel
268
263
  # define_attribute_methods :name, :age, :address
269
264
  #
270
265
  # private
271
- #
272
- # def clear_attribute(attr)
273
- # send("#{attr}=", nil)
274
- # end
266
+ # def clear_attribute(attr)
267
+ # send("#{attr}=", nil)
268
+ # end
275
269
  # end
276
270
  def define_attribute_methods(*attr_names)
277
271
  ActiveSupport::CodeGenerator.batch(generated_attribute_methods, __FILE__, __LINE__) do |owner|
@@ -298,10 +292,9 @@ module ActiveModel
298
292
  # define_attribute_method :name
299
293
  #
300
294
  # private
301
- #
302
- # def attribute_short?(attr)
303
- # send(attr).length < 5
304
- # end
295
+ # def attribute_short?(attr)
296
+ # send(attr).length < 5
297
+ # end
305
298
  # end
306
299
  #
307
300
  # person = Person.new
@@ -337,10 +330,9 @@ module ActiveModel
337
330
  # define_attribute_method :name
338
331
  #
339
332
  # private
340
- #
341
- # def attribute_short?(attr)
342
- # send(attr).length < 5
343
- # end
333
+ # def attribute_short?(attr)
334
+ # send(attr).length < 5
335
+ # end
344
336
  # end
345
337
  #
346
338
  # person = Person.new
@@ -43,8 +43,8 @@ module ActiveModel
43
43
 
44
44
  def changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
45
45
  attribute_changed?(attr_name) &&
46
- (OPTION_NOT_GIVEN == from || original_value(attr_name) == from) &&
47
- (OPTION_NOT_GIVEN == to || fetch_value(attr_name) == to)
46
+ (OPTION_NOT_GIVEN == from || original_value(attr_name) == type_cast(attr_name, from)) &&
47
+ (OPTION_NOT_GIVEN == to || fetch_value(attr_name) == type_cast(attr_name, to))
48
48
  end
49
49
 
50
50
  def changed_in_place?(attr_name)
@@ -82,6 +82,10 @@ module ActiveModel
82
82
  def fetch_value(attr_name)
83
83
  attributes.fetch_value(attr_name)
84
84
  end
85
+
86
+ def type_cast(attr_name, value)
87
+ attributes[attr_name].type_cast(value)
88
+ end
85
89
  end
86
90
 
87
91
  class ForcedMutationTracker < AttributeMutationTracker # :nodoc:
@@ -143,6 +147,10 @@ module ActiveModel
143
147
  rescue TypeError, NoMethodError
144
148
  value
145
149
  end
150
+
151
+ def type_cast(attr_name, value)
152
+ value
153
+ end
146
154
  end
147
155
 
148
156
  class NullMutationTracker # :nodoc:
@@ -74,7 +74,7 @@ module ActiveModel
74
74
  # <tt>:only</tt> option, where you can choose if you want all types (before,
75
75
  # around or after) or just some.
76
76
  #
77
- # define_model_callbacks :initializer, only: :after
77
+ # define_model_callbacks :initialize, only: :after
78
78
  #
79
79
  # Note, the <tt>only: <type></tt> hash will apply to all callbacks defined
80
80
  # on that method call. To get around this you can call the define_model_callbacks
@@ -9,8 +9,8 @@ module ActiveModel
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 4
13
- PRE = "3"
12
+ TINY = 5
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -31,7 +31,9 @@ module ActiveModel
31
31
 
32
32
  class Data # :nodoc:
33
33
  def initialize(value)
34
- @value = value.to_s
34
+ value = value.to_s
35
+ value = value.b unless value.encoding == Encoding::BINARY
36
+ @value = value
35
37
  end
36
38
 
37
39
  def to_s
@@ -4,6 +4,10 @@ module ActiveModel
4
4
  module Type
5
5
  module Helpers # :nodoc: all
6
6
  module Mutable
7
+ def immutable_value(value)
8
+ value.deep_dup.freeze
9
+ end
10
+
7
11
  def cast(value)
8
12
  deserialize(serialize(value))
9
13
  end
@@ -121,6 +121,10 @@ module ActiveModel
121
121
  def assert_valid_value(_)
122
122
  end
123
123
 
124
+ def immutable_value(value) # :nodoc:
125
+ value
126
+ end
127
+
124
128
  private
125
129
  # Convenience method for types which do not need separate type casting
126
130
  # behavior for user and database inputs. Called by Value#cast for
@@ -43,10 +43,9 @@ module ActiveModel
43
43
  # before_validation :remove_whitespaces
44
44
  #
45
45
  # private
46
- #
47
- # def remove_whitespaces
48
- # name.strip!
49
- # end
46
+ # def remove_whitespaces
47
+ # name.strip!
48
+ # end
50
49
  # end
51
50
  #
52
51
  # person = Person.new
@@ -74,10 +73,9 @@ module ActiveModel
74
73
  # after_validation :set_status
75
74
  #
76
75
  # private
77
- #
78
- # def set_status
79
- # self.status = errors.empty?
80
- # end
76
+ # def set_status
77
+ # self.status = errors.empty?
78
+ # end
81
79
  # end
82
80
  #
83
81
  # person = Person.new
@@ -85,10 +85,9 @@ module ActiveModel
85
85
  # validates_length_of :words_in_essay, minimum: 100, too_short: 'Your essay must be at least 100 words.'
86
86
  #
87
87
  # private
88
- #
89
- # def words_in_essay
90
- # essay.scan(/\w+/)
91
- # end
88
+ # def words_in_essay
89
+ # essay.scan(/\w+/)
90
+ # end
92
91
  # end
93
92
  #
94
93
  # Constraint options:
@@ -96,7 +96,7 @@ module ActiveModel
96
96
  # Example:
97
97
  #
98
98
  # validates :password, presence: true, confirmation: true, if: :password_required?
99
- # validates :token, length: 24, strict: TokenLengthException
99
+ # validates :token, length: { is: 24 }, strict: TokenLengthException
100
100
  #
101
101
  #
102
102
  # Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+, +:strict+
data/lib/active_model.rb CHANGED
@@ -58,6 +58,7 @@ module ActiveModel
58
58
  autoload :RangeError, "active_model/errors"
59
59
  autoload :StrictValidationFailed, "active_model/errors"
60
60
  autoload :UnknownAttributeError, "active_model/errors"
61
+ autoload :ValidationError, "active_model/validations"
61
62
  end
62
63
 
63
64
  module Serializers
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.0.4.3
4
+ version: 7.0.5
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: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2023-05-24 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.0.4.3
19
+ version: 7.0.5
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.0.4.3
26
+ version: 7.0.5
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.
@@ -107,12 +107,12 @@ licenses:
107
107
  - MIT
108
108
  metadata:
109
109
  bug_tracker_uri: https://github.com/rails/rails/issues
110
- changelog_uri: https://github.com/rails/rails/blob/v7.0.4.3/activemodel/CHANGELOG.md
111
- documentation_uri: https://api.rubyonrails.org/v7.0.4.3/
110
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.5/activemodel/CHANGELOG.md
111
+ documentation_uri: https://api.rubyonrails.org/v7.0.5/
112
112
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
113
- source_code_uri: https://github.com/rails/rails/tree/v7.0.4.3/activemodel
113
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.5/activemodel
114
114
  rubygems_mfa_required: 'true'
115
- post_install_message:
115
+ post_install_message:
116
116
  rdoc_options: []
117
117
  require_paths:
118
118
  - lib
@@ -127,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubygems_version: 3.4.3
131
- signing_key:
130
+ rubygems_version: 3.4.10
131
+ signing_key:
132
132
  specification_version: 4
133
133
  summary: A toolkit for building modeling frameworks (part of Rails).
134
134
  test_files: []