activemodel 6.0.2.2 → 6.0.3.rc1

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.rdoc +1 -1
  4. data/lib/active_model/attribute_assignment.rb +0 -1
  5. data/lib/active_model/attribute_methods.rb +2 -0
  6. data/lib/active_model/attribute_set.rb +0 -2
  7. data/lib/active_model/attributes.rb +0 -2
  8. data/lib/active_model/callbacks.rb +0 -1
  9. data/lib/active_model/dirty.rb +1 -1
  10. data/lib/active_model/errors.rb +2 -2
  11. data/lib/active_model/gem_version.rb +2 -2
  12. data/lib/active_model/naming.rb +1 -2
  13. data/lib/active_model/serialization.rb +0 -1
  14. data/lib/active_model/translation.rb +1 -1
  15. data/lib/active_model/type/big_integer.rb +0 -1
  16. data/lib/active_model/type/boolean.rb +0 -1
  17. data/lib/active_model/type/date.rb +0 -1
  18. data/lib/active_model/type/date_time.rb +0 -1
  19. data/lib/active_model/type/decimal.rb +0 -1
  20. data/lib/active_model/type/float.rb +0 -1
  21. data/lib/active_model/type/helpers/numeric.rb +0 -1
  22. data/lib/active_model/type/helpers/time_value.rb +0 -1
  23. data/lib/active_model/type/immutable_string.rb +0 -1
  24. data/lib/active_model/type/integer.rb +1 -1
  25. data/lib/active_model/type/registry.rb +4 -3
  26. data/lib/active_model/type/string.rb +0 -1
  27. data/lib/active_model/type/time.rb +0 -1
  28. data/lib/active_model/type/value.rb +0 -1
  29. data/lib/active_model/validations.rb +0 -1
  30. data/lib/active_model/validations/absence.rb +1 -1
  31. data/lib/active_model/validations/acceptance.rb +0 -1
  32. data/lib/active_model/validations/callbacks.rb +0 -1
  33. data/lib/active_model/validations/clusivity.rb +0 -1
  34. data/lib/active_model/validations/format.rb +1 -2
  35. data/lib/active_model/validations/numericality.rb +3 -2
  36. data/lib/active_model/validations/validates.rb +0 -1
  37. data/lib/active_model/validator.rb +0 -1
  38. metadata +11 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91b9778166a7482f6aee0249522ed7c8e1838952f9bd3f924e2e5a5049d084c0
4
- data.tar.gz: 39474a96bc3dbc3544750a543a1acc6694b889fff0bab8310804c07cd157ef19
3
+ metadata.gz: 595c281f790035eac513203ea725bf7a50aa7e504965776c94f46a33ca502532
4
+ data.tar.gz: c33cec437112dd55798c8523aa7d2dbc94d6f7b0af0ecbae328e0efb9ecceb82
5
5
  SHA512:
6
- metadata.gz: 0615ae83e10f7135db9c47d07c6bdf3812b56fc2107db8d09aa4c81f8d374d08b94bc2d6a53c1b35ccab0fcc76a224925babbc9c6452d320b19084eac102d983
7
- data.tar.gz: 0b7fd5938d672c09e4ad0b25ba61fa324e71f706de636f8c27d443d66330e8655784a46341b2a6cf5a94d9c4596019b29ce12fdebec3e8a48e53bd55ae35e5a4
6
+ metadata.gz: 7c9c0c71976e3affc15397abf6512ed0c234b799fcab6037bb8253472a30b2e4456ba69cc2c1a0f3980079a407bc0d34736928a8649cc45641662fc674332666
7
+ data.tar.gz: 94a1fa2806e4d298845874f1a533c5d94ed5356f69df39ba12f44645a38ec615db23bb88f139374a4901e437cfebfb1c07731fee69cc6e4017a87a8e03c59911
@@ -1,3 +1,13 @@
1
+ ## Rails 6.0.3.rc1 (April 30, 2020) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.0.2.2 (March 19, 2020) ##
7
+
8
+ * No changes.
9
+
10
+
1
11
  ## Rails 6.0.2.1 (December 18, 2019) ##
2
12
 
3
13
  * No changes.
@@ -263,4 +263,4 @@ Bug reports for the Ruby on Rails project can be filed here:
263
263
 
264
264
  Feature requests should be discussed on the rails-core mailing list here:
265
265
 
266
- * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
266
+ * https://discuss.rubyonrails.org/c/rubyonrails-core
@@ -38,7 +38,6 @@ module ActiveModel
38
38
  alias attributes= assign_attributes
39
39
 
40
40
  private
41
-
42
41
  def _assign_attributes(attributes)
43
42
  attributes.each do |k, v|
44
43
  _assign_attribute(k, v)
@@ -382,6 +382,7 @@ module ActiveModel
382
382
  #{defn}
383
383
  #{body}
384
384
  end
385
+ ruby2_keywords(:'#{name}') if respond_to?(:ruby2_keywords, true)
385
386
  RUBY
386
387
  end
387
388
 
@@ -431,6 +432,7 @@ module ActiveModel
431
432
  match ? attribute_missing(match, *args, &block) : super
432
433
  end
433
434
  end
435
+ ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
434
436
 
435
437
  # +attribute_missing+ is like +method_missing+, but for attributes. When
436
438
  # +method_missing+ is called we check to see if there is a matching
@@ -94,11 +94,9 @@ module ActiveModel
94
94
  end
95
95
 
96
96
  protected
97
-
98
97
  attr_reader :attributes
99
98
 
100
99
  private
101
-
102
100
  def initialized_attributes
103
101
  attributes.select { |_, attr| attr.initialized? }
104
102
  end
@@ -42,7 +42,6 @@ module ActiveModel
42
42
  end
43
43
 
44
44
  private
45
-
46
45
  def define_method_attribute=(name)
47
46
  ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
48
47
  generated_attribute_methods, name, writer: true,
@@ -114,7 +113,6 @@ module ActiveModel
114
113
  end
115
114
 
116
115
  private
117
-
118
116
  def write_attribute(attr_name, value)
119
117
  name = attr_name.to_s
120
118
  name = self.class.attribute_aliases[name] || name
@@ -126,7 +126,6 @@ module ActiveModel
126
126
  end
127
127
 
128
128
  private
129
-
130
129
  def _define_before_model_callback(klass, callback)
131
130
  klass.define_singleton_method("before_#{callback}") do |*args, **options, &block|
132
131
  options.assert_valid_keys(:if, :unless, :prepend)
@@ -167,7 +167,7 @@ module ActiveModel
167
167
 
168
168
  # Dispatch target for <tt>*_changed?</tt> attribute methods.
169
169
  def attribute_changed?(attr_name, **options) # :nodoc:
170
- mutations_from_database.changed?(attr_name.to_s, options)
170
+ mutations_from_database.changed?(attr_name.to_s, **options)
171
171
  end
172
172
 
173
173
  # Dispatch target for <tt>*_was</tt> attribute methods.
@@ -497,7 +497,7 @@ module ActiveModel
497
497
  defaults << :"#{i18n_scope}.errors.messages.#{type}"
498
498
 
499
499
  catch(:exception) do
500
- translation = I18n.translate(defaults.first, options.merge(default: defaults.drop(1), throw: true))
500
+ translation = I18n.translate(defaults.first, **options.merge(default: defaults.drop(1), throw: true))
501
501
  return translation unless translation.nil?
502
502
  end unless options[:message]
503
503
  else
@@ -511,7 +511,7 @@ module ActiveModel
511
511
  defaults = options.delete(:message) if options[:message]
512
512
  options[:default] = defaults
513
513
 
514
- I18n.translate(key, options)
514
+ I18n.translate(key, **options)
515
515
  end
516
516
 
517
517
  def marshal_dump # :nodoc:
@@ -9,8 +9,8 @@ module ActiveModel
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
- TINY = 2
13
- PRE = "2"
12
+ TINY = 3
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -203,11 +203,10 @@ module ActiveModel
203
203
  defaults << @human
204
204
 
205
205
  options = { scope: [@klass.i18n_scope, :models], count: 1, default: defaults }.merge!(options.except(:default))
206
- I18n.translate(defaults.shift, options)
206
+ I18n.translate(defaults.shift, **options)
207
207
  end
208
208
 
209
209
  private
210
-
211
210
  def _singularize(string)
212
211
  ActiveSupport::Inflector.underscore(string).tr("/", "_")
213
212
  end
@@ -150,7 +150,6 @@ module ActiveModel
150
150
  end
151
151
 
152
152
  private
153
-
154
153
  # Hook method defining how an attribute value should be retrieved for
155
154
  # serialization. By default this is assumed to be an instance named after
156
155
  # the attribute. Override this method in subclasses should you need to
@@ -64,7 +64,7 @@ module ActiveModel
64
64
  defaults << attribute.humanize
65
65
 
66
66
  options[:default] = defaults
67
- I18n.translate(defaults.shift, options)
67
+ I18n.translate(defaults.shift, **options)
68
68
  end
69
69
  end
70
70
  end
@@ -6,7 +6,6 @@ module ActiveModel
6
6
  module Type
7
7
  class BigInteger < Integer # :nodoc:
8
8
  private
9
-
10
9
  def max_value
11
10
  ::Float::INFINITY
12
11
  end
@@ -34,7 +34,6 @@ module ActiveModel
34
34
  end
35
35
 
36
36
  private
37
-
38
37
  def cast_value(value)
39
38
  if value == ""
40
39
  nil
@@ -15,7 +15,6 @@ module ActiveModel
15
15
  end
16
16
 
17
17
  private
18
-
19
18
  def cast_value(value)
20
19
  if value.is_a?(::String)
21
20
  return if value.empty?
@@ -14,7 +14,6 @@ module ActiveModel
14
14
  end
15
15
 
16
16
  private
17
-
18
17
  def cast_value(value)
19
18
  return apply_seconds_precision(value) unless value.is_a?(::String)
20
19
  return if value.empty?
@@ -17,7 +17,6 @@ module ActiveModel
17
17
  end
18
18
 
19
19
  private
20
-
21
20
  def cast_value(value)
22
21
  casted_value = \
23
22
  case value
@@ -19,7 +19,6 @@ module ActiveModel
19
19
  end
20
20
 
21
21
  private
22
-
23
22
  def cast_value(value)
24
23
  case value
25
24
  when ::Float then value
@@ -24,7 +24,6 @@ module ActiveModel
24
24
  end
25
25
 
26
26
  private
27
-
28
27
  def number_to_non_number?(old_value, new_value_before_type_cast)
29
28
  old_value != nil && non_numeric_string?(new_value_before_type_cast.to_s)
30
29
  end
@@ -44,7 +44,6 @@ module ActiveModel
44
44
  end
45
45
 
46
46
  private
47
-
48
47
  def new_time(year, mon, mday, hour, min, sec, microsec, offset = nil)
49
48
  # Treat 0000-00-00 00:00:00 as nil.
50
49
  return if year.nil? || (year == 0 && mon == 0 && mday == 0)
@@ -17,7 +17,6 @@ module ActiveModel
17
17
  end
18
18
 
19
19
  private
20
-
21
20
  def cast_value(value)
22
21
  result = \
23
22
  case value
@@ -9,7 +9,7 @@ module ActiveModel
9
9
  # 4 bytes means an integer as opposed to smallint etc.
10
10
  DEFAULT_LIMIT = 4
11
11
 
12
- def initialize(*)
12
+ def initialize(*, **)
13
13
  super
14
14
  @range = min_value...max_value
15
15
  end
@@ -10,14 +10,15 @@ module ActiveModel
10
10
 
11
11
  def register(type_name, klass = nil, **options, &block)
12
12
  block ||= proc { |_, *args| klass.new(*args) }
13
+ block.ruby2_keywords if block.respond_to?(:ruby2_keywords)
13
14
  registrations << registration_klass.new(type_name, block, **options)
14
15
  end
15
16
 
16
- def lookup(symbol, *args)
17
- registration = find_registration(symbol, *args)
17
+ def lookup(symbol, *args, **kwargs)
18
+ registration = find_registration(symbol, *args, **kwargs)
18
19
 
19
20
  if registration
20
- registration.call(self, symbol, *args)
21
+ registration.call(self, symbol, *args, **kwargs)
21
22
  else
22
23
  raise ArgumentError, "Unknown type #{symbol.inspect}"
23
24
  end
@@ -12,7 +12,6 @@ module ActiveModel
12
12
  end
13
13
 
14
14
  private
15
-
16
15
  def cast_value(value)
17
16
  case value
18
17
  when ::String then ::String.new(value)
@@ -29,7 +29,6 @@ module ActiveModel
29
29
  end
30
30
 
31
31
  private
32
-
33
32
  def cast_value(value)
34
33
  return apply_seconds_precision(value) unless value.is_a?(::String)
35
34
  return if value.empty?
@@ -114,7 +114,6 @@ module ActiveModel
114
114
  end
115
115
 
116
116
  private
117
-
118
117
  # Convenience method for types which do not need separate type casting
119
118
  # behavior for user and database inputs. Called by Value#cast for
120
119
  # values except +nil+.
@@ -402,7 +402,6 @@ module ActiveModel
402
402
  alias :read_attribute_for_validation :send
403
403
 
404
404
  private
405
-
406
405
  def run_validations!
407
406
  _run_validate_callbacks
408
407
  errors.empty?
@@ -11,7 +11,7 @@ module ActiveModel
11
11
 
12
12
  module HelperMethods
13
13
  # Validates that the specified attributes are blank (as defined by
14
- # Object#blank?). Happens by default on save.
14
+ # Object#present?). Happens by default on save.
15
15
  #
16
16
  # class Person < ActiveRecord::Base
17
17
  # validates_absence_of :first_name
@@ -15,7 +15,6 @@ module ActiveModel
15
15
  end
16
16
 
17
17
  private
18
-
19
18
  def setup!(klass)
20
19
  define_attributes = LazilyDefineAttributes.new(attributes)
21
20
  klass.include(define_attributes) unless klass.included_modules.include?(define_attributes)
@@ -112,7 +112,6 @@ module ActiveModel
112
112
  end
113
113
 
114
114
  private
115
-
116
115
  # Overwrite run validations to include callbacks.
117
116
  def run_validations!
118
117
  _run_validation_callbacks { super }
@@ -15,7 +15,6 @@ module ActiveModel
15
15
  end
16
16
 
17
17
  private
18
-
19
18
  def include?(record, value)
20
19
  members = if delimiter.respond_to?(:call)
21
20
  delimiter.call(record)
@@ -6,7 +6,7 @@ module ActiveModel
6
6
  def validate_each(record, attribute, value)
7
7
  if options[:with]
8
8
  regexp = option_call(record, :with)
9
- record_error(record, attribute, :with, value) if value.to_s !~ regexp
9
+ record_error(record, attribute, :with, value) if !value.to_s&.match?(regexp)
10
10
  elsif options[:without]
11
11
  regexp = option_call(record, :without)
12
12
  record_error(record, attribute, :without, value) if regexp.match?(value.to_s)
@@ -23,7 +23,6 @@ module ActiveModel
23
23
  end
24
24
 
25
25
  private
26
-
27
26
  def option_call(record, name)
28
27
  option = options[name]
29
28
  option.respond_to?(:call) ? option.call(record) : option
@@ -13,6 +13,8 @@ module ActiveModel
13
13
 
14
14
  INTEGER_REGEX = /\A[+-]?\d+\z/
15
15
 
16
+ HEXADECIMAL_REGEX = /\A[+-]?0[xX]/
17
+
16
18
  def check_validity!
17
19
  keys = CHECKS.keys - [:odd, :even]
18
20
  options.slice(*keys).each do |option, value|
@@ -79,7 +81,6 @@ module ActiveModel
79
81
  end
80
82
 
81
83
  private
82
-
83
84
  def is_number?(raw_value)
84
85
  !parse_as_number(raw_value).nil?
85
86
  rescue ArgumentError, TypeError
@@ -103,7 +104,7 @@ module ActiveModel
103
104
  end
104
105
 
105
106
  def is_hexadecimal_literal?(raw_value)
106
- /\A0[xX]/.match?(raw_value.to_s)
107
+ HEXADECIMAL_REGEX.match?(raw_value.to_s)
107
108
  end
108
109
 
109
110
  def filtered_options(value)
@@ -150,7 +150,6 @@ module ActiveModel
150
150
  end
151
151
 
152
152
  private
153
-
154
153
  # When creating custom validators, it might be useful to be able to specify
155
154
  # additional default keys. This can be done by overwriting this method.
156
155
  def _validates_default_keys
@@ -175,7 +175,6 @@ module ActiveModel
175
175
  end
176
176
 
177
177
  private
178
-
179
178
  def validate_each(record, attribute, value)
180
179
  @block.call(record, attribute, value)
181
180
  end
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: 6.0.2.2
4
+ version: 6.0.3.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-19 00:00:00.000000000 Z
11
+ date: 2020-05-01 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: 6.0.2.2
19
+ version: 6.0.3.rc1
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: 6.0.2.2
26
+ version: 6.0.3.rc1
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.
@@ -102,10 +102,10 @@ licenses:
102
102
  - MIT
103
103
  metadata:
104
104
  bug_tracker_uri: https://github.com/rails/rails/issues
105
- changelog_uri: https://github.com/rails/rails/blob/v6.0.2.2/activemodel/CHANGELOG.md
106
- documentation_uri: https://api.rubyonrails.org/v6.0.2.2/
107
- mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
108
- source_code_uri: https://github.com/rails/rails/tree/v6.0.2.2/activemodel
105
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.3.rc1/activemodel/CHANGELOG.md
106
+ documentation_uri: https://api.rubyonrails.org/v6.0.3.rc1/
107
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
108
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.3.rc1/activemodel
109
109
  post_install_message:
110
110
  rdoc_options: []
111
111
  require_paths:
@@ -117,11 +117,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: 2.5.0
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - ">"
121
121
  - !ruby/object:Gem::Version
122
- version: '0'
122
+ version: 1.3.1
123
123
  requirements: []
124
- rubygems_version: 3.0.3
124
+ rubygems_version: 3.1.2
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: A toolkit for building modeling frameworks (part of Rails).