activemodel 5.2.1.1 → 5.2.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/active_model/attribute.rb +1 -0
- data/lib/active_model/dirty.rb +3 -1
- data/lib/active_model/errors.rb +3 -3
- data/lib/active_model/gem_version.rb +2 -2
- data/lib/active_model/type/helpers/numeric.rb +1 -1
- data/lib/active_model/validations/numericality.rb +16 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 337a43f3957744aee93260ae4f6fd4ae69f6ee02ce3d6bec715704f328e2e65a
|
4
|
+
data.tar.gz: db21100aba18efbf69894d52b19df6a0480d0b540f12e4d2d0f1b016415e4b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3620ed5a6213e665798c3c0f3c2685396921f5c5fbafecff19c6e6cffc19acc49df9fc690674da35833c08732f21f6fb109254128f89b0d5c62c512fd3c91cae
|
7
|
+
data.tar.gz: 7f9a71461be3a394d7513431e6e67ccf084fc6911cfd737f74457d9278f64773d167d5dde7dce38b2a8fa47d792dbba4718c7e11f48c13cbde7ef1071c22152d
|
data/CHANGELOG.md
CHANGED
@@ -207,6 +207,7 @@ module ActiveModel
|
|
207
207
|
raise ActiveModel::MissingAttributeError, "can't write unknown attribute `#{name}`"
|
208
208
|
end
|
209
209
|
alias_method :with_value_from_user, :with_value_from_database
|
210
|
+
alias_method :with_cast_value, :with_value_from_database
|
210
211
|
end
|
211
212
|
|
212
213
|
class Uninitialized < Attribute # :nodoc:
|
data/lib/active_model/dirty.rb
CHANGED
@@ -141,7 +141,9 @@ module ActiveModel
|
|
141
141
|
@mutations_from_database = nil
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
# Clears dirty data and moves +changes+ to +previously_changed+ and
|
145
|
+
# +mutations_from_database+ to +mutations_before_last_save+ respectively.
|
146
|
+
def changes_applied
|
145
147
|
unless defined?(@attributes)
|
146
148
|
@previously_changed = changes
|
147
149
|
end
|
data/lib/active_model/errors.rb
CHANGED
@@ -322,11 +322,11 @@ module ActiveModel
|
|
322
322
|
# person.errors.added? :name, :too_long # => false
|
323
323
|
# person.errors.added? :name, "is too long" # => false
|
324
324
|
def added?(attribute, message = :invalid, options = {})
|
325
|
+
message = message.call if message.respond_to?(:call)
|
326
|
+
|
325
327
|
if message.is_a? Symbol
|
326
|
-
|
328
|
+
details[attribute.to_sym].include? normalize_detail(message, options)
|
327
329
|
else
|
328
|
-
message = message.call if message.respond_to?(:call)
|
329
|
-
message = normalize_message(attribute, message, options)
|
330
330
|
self[attribute].include? message
|
331
331
|
end
|
332
332
|
end
|
@@ -21,8 +21,17 @@ module ActiveModel
|
|
21
21
|
def validate_each(record, attr_name, value)
|
22
22
|
came_from_user = :"#{attr_name}_came_from_user?"
|
23
23
|
|
24
|
-
if record.respond_to?(came_from_user)
|
25
|
-
|
24
|
+
if record.respond_to?(came_from_user)
|
25
|
+
if record.public_send(came_from_user)
|
26
|
+
raw_value = record.read_attribute_before_type_cast(attr_name)
|
27
|
+
elsif record.respond_to?(:read_attribute)
|
28
|
+
raw_value = record.read_attribute(attr_name)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
before_type_cast = :"#{attr_name}_before_type_cast"
|
32
|
+
if record.respond_to?(before_type_cast)
|
33
|
+
raw_value = record.public_send(before_type_cast)
|
34
|
+
end
|
26
35
|
end
|
27
36
|
raw_value ||= value
|
28
37
|
|
@@ -77,13 +86,17 @@ module ActiveModel
|
|
77
86
|
|
78
87
|
def parse_raw_value_as_a_number(raw_value)
|
79
88
|
return raw_value.to_i if is_integer?(raw_value)
|
80
|
-
Kernel.Float(raw_value)
|
89
|
+
Kernel.Float(raw_value) unless is_hexadecimal_literal?(raw_value)
|
81
90
|
end
|
82
91
|
|
83
92
|
def is_integer?(raw_value)
|
84
93
|
/\A[+-]?\d+\z/ === raw_value.to_s
|
85
94
|
end
|
86
95
|
|
96
|
+
def is_hexadecimal_literal?(raw_value)
|
97
|
+
/\A0[xX]/ === raw_value
|
98
|
+
end
|
99
|
+
|
87
100
|
def filtered_options(value)
|
88
101
|
filtered = options.except(*RESERVED_OPTIONS)
|
89
102
|
filtered[:value] = value
|
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: 5.2.
|
4
|
+
version: 5.2.2.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: 2018-11-
|
11
|
+
date: 2018-11-28 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: 5.2.
|
19
|
+
version: 5.2.2.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: 5.2.
|
26
|
+
version: 5.2.2.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.
|
@@ -100,8 +100,8 @@ homepage: http://rubyonrails.org
|
|
100
100
|
licenses:
|
101
101
|
- MIT
|
102
102
|
metadata:
|
103
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.
|
104
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.
|
103
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.2.rc1/activemodel
|
104
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.2.rc1/activemodel/CHANGELOG.md
|
105
105
|
post_install_message:
|
106
106
|
rdoc_options: []
|
107
107
|
require_paths:
|
@@ -113,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: 2.2.2
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - "
|
116
|
+
- - ">"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
118
|
+
version: 1.3.1
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
121
|
rubygems_version: 2.7.6
|