activemodel 5.0.0.beta2 → 5.0.0.beta3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/active_model/errors.rb +11 -2
- data/lib/active_model/gem_version.rb +1 -1
- data/lib/active_model/validator.rb +0 -4
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c283ac88f7c8c09878346cd9ac5317371c141bb6
|
4
|
+
data.tar.gz: 9141a1af7e5100d957d9192e0e2beae4306e2c68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 069aec401e7854c4d2e3e578ed6d4226f07d9411049b262ef1d5a81ab639c9d34aff29e22af5676a0ec065b98a4ef9e0cf5b31c2d228aff833d70465de61cf21
|
7
|
+
data.tar.gz: a4e7860c438a2ac4933cdada88fe0e84c0154870ec7fbd88f60d6b53f1d4c3e1824ac494f7f54871c9bd7b72f299890b9c2c5efdbf1f937e68297ddd0c9ec26b
|
data/CHANGELOG.md
CHANGED
data/lib/active_model/errors.rb
CHANGED
@@ -160,6 +160,15 @@ module ActiveModel
|
|
160
160
|
#
|
161
161
|
# person.errors[:name] # => ["cannot be nil"]
|
162
162
|
# person.errors['name'] # => ["cannot be nil"]
|
163
|
+
#
|
164
|
+
# Note that, if you try to get errors of an attribute which has
|
165
|
+
# no errors associated with it, this method will instantiate
|
166
|
+
# an empty error list for it and +keys+ will return an array
|
167
|
+
# of error keys which includes this attribute.
|
168
|
+
#
|
169
|
+
# person.errors.keys # => []
|
170
|
+
# person.errors[:name] # => []
|
171
|
+
# person.errors.keys # => [:name]
|
163
172
|
def [](attribute)
|
164
173
|
messages[attribute.to_sym]
|
165
174
|
end
|
@@ -318,7 +327,7 @@ module ActiveModel
|
|
318
327
|
# # => {:base=>[{error: :name_or_email_blank}]}
|
319
328
|
def add(attribute, message = :invalid, options = {})
|
320
329
|
message = message.call if message.respond_to?(:call)
|
321
|
-
detail = normalize_detail(
|
330
|
+
detail = normalize_detail(message, options)
|
322
331
|
message = normalize_message(attribute, message, options)
|
323
332
|
if exception = options[:strict]
|
324
333
|
exception = ActiveModel::StrictValidationFailed if exception == true
|
@@ -493,7 +502,7 @@ module ActiveModel
|
|
493
502
|
end
|
494
503
|
end
|
495
504
|
|
496
|
-
def normalize_detail(
|
505
|
+
def normalize_detail(message, options)
|
497
506
|
{ error: message }.merge(options.except(*CALLBACKS_OPTIONS + MESSAGE_OPTIONS))
|
498
507
|
end
|
499
508
|
end
|
@@ -163,10 +163,6 @@ module ActiveModel
|
|
163
163
|
# +ArgumentError+ when invalid options are supplied.
|
164
164
|
def check_validity!
|
165
165
|
end
|
166
|
-
|
167
|
-
def should_validate?(record) # :nodoc:
|
168
|
-
!record.persisted? || record.changed? || record.marked_for_destruction?
|
169
|
-
end
|
170
166
|
end
|
171
167
|
|
172
168
|
# +BlockValidator+ is a special +EachValidator+ which receives a block on initialization
|
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.0.0.
|
4
|
+
version: 5.0.0.beta3
|
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: 2016-02-
|
11
|
+
date: 2016-02-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: 5.0.0.
|
19
|
+
version: 5.0.0.beta3
|
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.0.0.
|
26
|
+
version: 5.0.0.beta3
|
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.
|
@@ -113,9 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: 1.3.1
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.5.
|
116
|
+
rubygems_version: 2.5.1
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: A toolkit for building modeling frameworks (part of Rails).
|
120
120
|
test_files: []
|
121
|
-
has_rdoc:
|