activemodel 3.2.1 → 3.2.2.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.
data/CHANGELOG.md
CHANGED
@@ -263,7 +263,7 @@ module ActiveModel
|
|
263
263
|
unless instance_method_already_implemented?(method_name)
|
264
264
|
generate_method = "define_method_#{matcher.method_missing_target}"
|
265
265
|
|
266
|
-
if respond_to?(generate_method)
|
266
|
+
if respond_to?(generate_method, true)
|
267
267
|
send(generate_method, attr_name)
|
268
268
|
else
|
269
269
|
define_optimized_call generated_attribute_methods, method_name, matcher.method_missing_target, attr_name.to_s
|
data/lib/active_model/errors.rb
CHANGED
@@ -233,7 +233,7 @@ module ActiveModel
|
|
233
233
|
def add(attribute, message = nil, options = {})
|
234
234
|
message = normalize_message(attribute, message, options)
|
235
235
|
if options[:strict]
|
236
|
-
raise ActiveModel::StrictValidationFailed,
|
236
|
+
raise ActiveModel::StrictValidationFailed, full_message(attribute, message)
|
237
237
|
end
|
238
238
|
|
239
239
|
self[attribute] << message
|
@@ -224,12 +224,12 @@ module ActiveModel
|
|
224
224
|
|
225
225
|
protected
|
226
226
|
|
227
|
-
def sanitize_for_mass_assignment(attributes, role =
|
227
|
+
def sanitize_for_mass_assignment(attributes, role = nil)
|
228
228
|
_mass_assignment_sanitizer.sanitize(attributes, mass_assignment_authorizer(role))
|
229
229
|
end
|
230
230
|
|
231
|
-
def mass_assignment_authorizer(role
|
232
|
-
self.class.active_authorizer[role]
|
231
|
+
def mass_assignment_authorizer(role)
|
232
|
+
self.class.active_authorizer[role || :default]
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/hash/slice'
|
2
2
|
|
3
3
|
module ActiveModel
|
4
|
-
|
5
4
|
# == Active Model validates method
|
6
5
|
module Validations
|
7
6
|
module ClassMethods
|
@@ -59,7 +58,7 @@ module ActiveModel
|
|
59
58
|
#
|
60
59
|
# validates :name, :'film/title' => true
|
61
60
|
#
|
62
|
-
# The validators hash can also handle regular expressions, ranges,
|
61
|
+
# The validators hash can also handle regular expressions, ranges,
|
63
62
|
# arrays and strings in shortcut form, e.g.
|
64
63
|
#
|
65
64
|
# validates :email, :format => /@/
|
@@ -70,7 +69,7 @@ module ActiveModel
|
|
70
69
|
# validator's initializer as +options[:in]+ while other types including
|
71
70
|
# regular expressions and strings are passed as +options[:with]+
|
72
71
|
#
|
73
|
-
# Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+ and +:strict+
|
72
|
+
# Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+ and +:strict+
|
74
73
|
# can be given to one specific validator, as a hash:
|
75
74
|
#
|
76
75
|
# validates :password, :presence => { :if => :password_required? }, :confirmation => true
|
@@ -101,11 +100,11 @@ module ActiveModel
|
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
104
|
-
# This method is used to define validation that
|
105
|
-
# and is considered exceptional.
|
106
|
-
#
|
107
|
-
#
|
108
|
-
# when validation fails
|
103
|
+
# This method is used to define validation that cannot be corrected by end
|
104
|
+
# user and is considered exceptional. So each validator defined with bang
|
105
|
+
# or <tt>:strict</tt> option set to <tt>true</tt> will always raise
|
106
|
+
# <tt>ActiveModel::StrictValidationFailed</tt> instead of adding error
|
107
|
+
# when validation fails.
|
109
108
|
# See <tt>validates</tt> for more information about validation itself.
|
110
109
|
def validates!(*attributes)
|
111
110
|
options = attributes.extract_options!
|
@@ -118,7 +117,7 @@ module ActiveModel
|
|
118
117
|
# When creating custom validators, it might be useful to be able to specify
|
119
118
|
# additional default keys. This can be done by overwriting this method.
|
120
119
|
def _validates_default_keys
|
121
|
-
[
|
120
|
+
[:if, :unless, :on, :allow_blank, :allow_nil , :strict]
|
122
121
|
end
|
123
122
|
|
124
123
|
def _parse_validates_options(options) #:nodoc:
|
data/lib/active_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15424071
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
+
- 2
|
10
|
+
- rc
|
9
11
|
- 1
|
10
|
-
version: 3.2.
|
12
|
+
version: 3.2.2.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- David Heinemeier Hansson
|
@@ -15,8 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-
|
19
|
-
default_executable:
|
20
|
+
date: 2012-02-22 00:00:00 Z
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
23
|
name: activesupport
|
@@ -26,12 +27,14 @@ dependencies:
|
|
26
27
|
requirements:
|
27
28
|
- - "="
|
28
29
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
30
|
+
hash: 15424071
|
30
31
|
segments:
|
31
32
|
- 3
|
32
33
|
- 2
|
34
|
+
- 2
|
35
|
+
- rc
|
33
36
|
- 1
|
34
|
-
version: 3.2.
|
37
|
+
version: 3.2.2.rc1
|
35
38
|
type: :runtime
|
36
39
|
version_requirements: *id001
|
37
40
|
- !ruby/object:Gem::Dependency
|
@@ -62,42 +65,41 @@ files:
|
|
62
65
|
- CHANGELOG.md
|
63
66
|
- MIT-LICENSE
|
64
67
|
- README.rdoc
|
68
|
+
- lib/active_model/attribute_methods.rb
|
69
|
+
- lib/active_model/callbacks.rb
|
70
|
+
- lib/active_model/conversion.rb
|
71
|
+
- lib/active_model/dirty.rb
|
72
|
+
- lib/active_model/errors.rb
|
73
|
+
- lib/active_model/lint.rb
|
65
74
|
- lib/active_model/locale/en.yml
|
66
|
-
- lib/active_model/mass_assignment_security/sanitizer.rb
|
67
75
|
- lib/active_model/mass_assignment_security/permission_set.rb
|
68
|
-
- lib/active_model/
|
69
|
-
- lib/active_model/observer_array.rb
|
70
|
-
- lib/active_model/test_case.rb
|
71
|
-
- lib/active_model/translation.rb
|
72
|
-
- lib/active_model/naming.rb
|
76
|
+
- lib/active_model/mass_assignment_security/sanitizer.rb
|
73
77
|
- lib/active_model/mass_assignment_security.rb
|
74
|
-
- lib/active_model/
|
75
|
-
- lib/active_model/
|
78
|
+
- lib/active_model/naming.rb
|
79
|
+
- lib/active_model/observer_array.rb
|
76
80
|
- lib/active_model/observing.rb
|
77
|
-
- lib/active_model/
|
78
|
-
- lib/active_model/
|
79
|
-
- lib/active_model/
|
80
|
-
- lib/active_model/dirty.rb
|
81
|
-
- lib/active_model/conversion.rb
|
82
|
-
- lib/active_model/serializers/xml.rb
|
81
|
+
- lib/active_model/railtie.rb
|
82
|
+
- lib/active_model/secure_password.rb
|
83
|
+
- lib/active_model/serialization.rb
|
83
84
|
- lib/active_model/serializers/json.rb
|
84
|
-
- lib/active_model/
|
85
|
-
- lib/active_model/
|
86
|
-
- lib/active_model/
|
85
|
+
- lib/active_model/serializers/xml.rb
|
86
|
+
- lib/active_model/test_case.rb
|
87
|
+
- lib/active_model/translation.rb
|
87
88
|
- lib/active_model/validations/acceptance.rb
|
88
|
-
- lib/active_model/validations/inclusion.rb
|
89
|
-
- lib/active_model/validations/format.rb
|
90
89
|
- lib/active_model/validations/callbacks.rb
|
91
90
|
- lib/active_model/validations/confirmation.rb
|
91
|
+
- lib/active_model/validations/exclusion.rb
|
92
|
+
- lib/active_model/validations/format.rb
|
93
|
+
- lib/active_model/validations/inclusion.rb
|
94
|
+
- lib/active_model/validations/length.rb
|
95
|
+
- lib/active_model/validations/numericality.rb
|
96
|
+
- lib/active_model/validations/presence.rb
|
92
97
|
- lib/active_model/validations/validates.rb
|
93
98
|
- lib/active_model/validations/with.rb
|
94
|
-
- lib/active_model/validations
|
95
|
-
- lib/active_model/lint.rb
|
96
|
-
- lib/active_model/attribute_methods.rb
|
99
|
+
- lib/active_model/validations.rb
|
97
100
|
- lib/active_model/validator.rb
|
98
|
-
- lib/active_model/
|
101
|
+
- lib/active_model/version.rb
|
99
102
|
- lib/active_model.rb
|
100
|
-
has_rdoc: true
|
101
103
|
homepage: http://www.rubyonrails.org
|
102
104
|
licenses: []
|
103
105
|
|
@@ -120,16 +122,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
123
|
none: false
|
122
124
|
requirements:
|
123
|
-
- - "
|
125
|
+
- - ">"
|
124
126
|
- !ruby/object:Gem::Version
|
125
|
-
hash:
|
127
|
+
hash: 25
|
126
128
|
segments:
|
127
|
-
-
|
128
|
-
|
129
|
+
- 1
|
130
|
+
- 3
|
131
|
+
- 1
|
132
|
+
version: 1.3.1
|
129
133
|
requirements: []
|
130
134
|
|
131
135
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.
|
136
|
+
rubygems_version: 1.8.16
|
133
137
|
signing_key:
|
134
138
|
specification_version: 3
|
135
139
|
summary: A toolkit for building modeling frameworks (part of Rails).
|