activemodel 3.1.1 → 3.1.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +110 -0
- data/lib/active_model/validations/validates.rb +3 -3
- data/lib/active_model/validations/with.rb +2 -2
- data/lib/active_model/validator.rb +4 -4
- data/lib/active_model/version.rb +2 -2
- metadata +49 -45
- data/CHANGELOG +0 -110
data/CHANGELOG.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
## Rails 3.1.1 (October 7, 2011) ##
|
2
|
+
|
3
|
+
* Remove hard dependency on bcrypt-ruby to avoid make ActiveModel dependent on a binary library.
|
4
|
+
You must add the gem explicitly to your Gemfile if you want use ActiveModel::SecurePassword:
|
5
|
+
|
6
|
+
gem 'bcrypt-ruby', '~> 3.0.0'
|
7
|
+
|
8
|
+
See GH #2687. *Guillermo Iguaran*
|
9
|
+
|
10
|
+
## Rails 3.1.0 (August 30, 2011) ##
|
11
|
+
|
12
|
+
* Alternate I18n namespace lookup is no longer supported.
|
13
|
+
Instead of "activerecord.models.admins.post", do "activerecord.models.admins/post" instead *José Valim*
|
14
|
+
|
15
|
+
* attr_accessible and friends now accepts :as as option to specify a role *Josh Kalderimis*
|
16
|
+
|
17
|
+
* Add support for proc or lambda as an option for InclusionValidator,
|
18
|
+
ExclusionValidator, and FormatValidator *Prem Sichanugrist*
|
19
|
+
|
20
|
+
You can now supply Proc, lambda, or anything that respond to #call in those
|
21
|
+
validations, and it will be called with current record as an argument.
|
22
|
+
That given proc or lambda must returns an object which respond to #include? for
|
23
|
+
InclusionValidator and ExclusionValidator, and returns a regular expression
|
24
|
+
object for FormatValidator.
|
25
|
+
|
26
|
+
* Added ActiveModel::SecurePassword to encapsulate dead-simple password usage with BCrypt encryption and salting *DHH*
|
27
|
+
|
28
|
+
* ActiveModel::AttributeMethods allows attributes to be defined on demand *Alexander Uvarov*
|
29
|
+
|
30
|
+
* Add support for selectively enabling/disabling observers *Myron Marston*
|
31
|
+
|
32
|
+
|
33
|
+
## Rails 3.0.7 (April 18, 2011) ##
|
34
|
+
|
35
|
+
* No changes.
|
36
|
+
|
37
|
+
|
38
|
+
* Rails 3.0.6 (April 5, 2011)
|
39
|
+
|
40
|
+
* Fix when database column name has some symbolic characters (e.g. Oracle CASE# VARCHAR2(20)) #5818 #6850 *Robert Pankowecki, Santiago Pastorino*
|
41
|
+
|
42
|
+
* Fix length validation for fixnums #6556 *Andriy Tyurnikov*
|
43
|
+
|
44
|
+
* Fix i18n key collision with namespaced models #6448 *yves.senn*
|
45
|
+
|
46
|
+
|
47
|
+
## Rails 3.0.5 (February 26, 2011) ##
|
48
|
+
|
49
|
+
* No changes.
|
50
|
+
|
51
|
+
|
52
|
+
## Rails 3.0.4 (February 8, 2011) ##
|
53
|
+
|
54
|
+
* No changes.
|
55
|
+
|
56
|
+
|
57
|
+
## Rails 3.0.3 (November 16, 2010) ##
|
58
|
+
|
59
|
+
* No changes.
|
60
|
+
|
61
|
+
|
62
|
+
## Rails 3.0.2 (November 15, 2010) ##
|
63
|
+
|
64
|
+
* No changes
|
65
|
+
|
66
|
+
|
67
|
+
## Rails 3.0.1 (October 15, 2010) ##
|
68
|
+
|
69
|
+
* No Changes, just a version bump.
|
70
|
+
|
71
|
+
|
72
|
+
## Rails 3.0.0 (August 29, 2010) ##
|
73
|
+
|
74
|
+
* Added ActiveModel::MassAssignmentSecurity *Eric Chapweske, Josh Kalderimis*
|
75
|
+
|
76
|
+
* JSON supports a custom root option: to_json(:root => 'custom') #4515 *Jatinder Singh*
|
77
|
+
|
78
|
+
* #new_record? and #destroyed? were removed from ActiveModel::Lint. Use
|
79
|
+
persisted? instead. A model is persisted if it's not a new_record? and it was
|
80
|
+
not destroyed? *MG*
|
81
|
+
|
82
|
+
* Added validations reflection in ActiveModel::Validations *JV*
|
83
|
+
|
84
|
+
Model.validators
|
85
|
+
Model.validators_on(:field)
|
86
|
+
|
87
|
+
* #to_key was added to ActiveModel::Lint so we can generate DOM IDs for
|
88
|
+
AMo objects with composite keys *MG*
|
89
|
+
|
90
|
+
* ActiveModel::Observer#add_observer!
|
91
|
+
|
92
|
+
It has a custom hook to define after_find that should really be in a
|
93
|
+
ActiveRecord::Observer subclass:
|
94
|
+
|
95
|
+
def add_observer!(klass)
|
96
|
+
klass.add_observer(self)
|
97
|
+
klass.class_eval 'def after_find() end' unless klass.respond_to?(:after_find)
|
98
|
+
end
|
99
|
+
|
100
|
+
* Change the ActiveModel::Base.include_root_in_json default to true for Rails 3 *DHH*
|
101
|
+
|
102
|
+
* Add validates_format_of :without => /regexp/ option. #430 *Elliot Winkler, Peer Allan*
|
103
|
+
|
104
|
+
Example :
|
105
|
+
|
106
|
+
validates_format_of :subdomain, :without => /www|admin|mail/
|
107
|
+
|
108
|
+
* Introduce validates_with to encapsulate attribute validations in a class. #2630 *Jeff Dean*
|
109
|
+
|
110
|
+
* Extracted from Active Record and Active Resource.
|
@@ -27,7 +27,7 @@ module ActiveModel
|
|
27
27
|
#
|
28
28
|
# class EmailValidator < ActiveModel::EachValidator
|
29
29
|
# def validate_each(record, attribute, value)
|
30
|
-
# record.errors
|
30
|
+
# record.errors.add attribute, (options[:message] || "is not an email") unless
|
31
31
|
# value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
|
32
32
|
# end
|
33
33
|
# end
|
@@ -48,7 +48,7 @@ module ActiveModel
|
|
48
48
|
#
|
49
49
|
# class TitleValidator < ActiveModel::EachValidator
|
50
50
|
# def validate_each(record, attribute, value)
|
51
|
-
# record.errors
|
51
|
+
# record.errors.add attribute, "must start with 'the'" unless value =~ /\Athe/i
|
52
52
|
# end
|
53
53
|
# end
|
54
54
|
#
|
@@ -57,7 +57,7 @@ module ActiveModel
|
|
57
57
|
#
|
58
58
|
# Additionally validator classes may be in another namespace and still used within any class.
|
59
59
|
#
|
60
|
-
# validates :name, :'
|
60
|
+
# validates :name, :'film/title' => true
|
61
61
|
#
|
62
62
|
# The validators hash can also handle regular expressions, ranges,
|
63
63
|
# arrays and strings in shortcut form, e.g.
|
@@ -32,7 +32,7 @@ module ActiveModel
|
|
32
32
|
# class MyValidator < ActiveModel::Validator
|
33
33
|
# def validate(record)
|
34
34
|
# if some_complex_logic
|
35
|
-
# record.errors
|
35
|
+
# record.errors.add :base, "This record is invalid"
|
36
36
|
# end
|
37
37
|
# end
|
38
38
|
#
|
@@ -140,4 +140,4 @@ module ActiveModel
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
|
-
end
|
143
|
+
end
|
@@ -48,8 +48,8 @@ module ActiveModel #:nodoc:
|
|
48
48
|
#
|
49
49
|
# class MyValidator < ActiveModel::Validator
|
50
50
|
# def validate(record)
|
51
|
-
# record.errors
|
52
|
-
# record.errors
|
51
|
+
# record.errors.add :base, "This is some custom error message"
|
52
|
+
# record.errors.add :first_name, "This is some complex validation"
|
53
53
|
# # etc...
|
54
54
|
# end
|
55
55
|
# end
|
@@ -57,7 +57,7 @@ module ActiveModel #:nodoc:
|
|
57
57
|
# To add behavior to the initialize method, use the following signature:
|
58
58
|
#
|
59
59
|
# class MyValidator < ActiveModel::Validator
|
60
|
-
# def initialize(
|
60
|
+
# def initialize(options)
|
61
61
|
# super
|
62
62
|
# @my_custom_field = options[:field_name] || :first_name
|
63
63
|
# end
|
@@ -68,7 +68,7 @@ module ActiveModel #:nodoc:
|
|
68
68
|
#
|
69
69
|
# class TitleValidator < ActiveModel::EachValidator
|
70
70
|
# def validate_each(record, attribute, value)
|
71
|
-
# record.errors
|
71
|
+
# record.errors.add attribute, 'must be Mr. Mrs. or Dr.' unless value.in?(['Mr.', 'Mrs.', 'Dr.'])
|
72
72
|
# end
|
73
73
|
# end
|
74
74
|
#
|
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: 15424119
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
+
- 2
|
10
|
+
- rc
|
9
11
|
- 1
|
10
|
-
version: 3.1.
|
12
|
+
version: 3.1.2.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- David Heinemeier Hansson
|
@@ -15,29 +17,31 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
20
|
+
date: 2011-11-14 00:00:00 Z
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
23
|
name: activesupport
|
24
|
+
type: :runtime
|
23
25
|
prerelease: false
|
24
|
-
|
26
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
27
|
none: false
|
26
28
|
requirements:
|
27
29
|
- - "="
|
28
30
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
31
|
+
hash: 15424119
|
30
32
|
segments:
|
31
33
|
- 3
|
32
34
|
- 1
|
35
|
+
- 2
|
36
|
+
- rc
|
33
37
|
- 1
|
34
|
-
version: 3.1.
|
35
|
-
|
36
|
-
version_requirements: *id001
|
38
|
+
version: 3.1.2.rc1
|
39
|
+
requirement: *id001
|
37
40
|
- !ruby/object:Gem::Dependency
|
38
41
|
name: builder
|
42
|
+
type: :runtime
|
39
43
|
prerelease: false
|
40
|
-
|
44
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
45
|
none: false
|
42
46
|
requirements:
|
43
47
|
- - ~>
|
@@ -48,12 +52,12 @@ dependencies:
|
|
48
52
|
- 0
|
49
53
|
- 0
|
50
54
|
version: 3.0.0
|
51
|
-
|
52
|
-
version_requirements: *id002
|
55
|
+
requirement: *id002
|
53
56
|
- !ruby/object:Gem::Dependency
|
54
57
|
name: i18n
|
58
|
+
type: :runtime
|
55
59
|
prerelease: false
|
56
|
-
|
60
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
57
61
|
none: false
|
58
62
|
requirements:
|
59
63
|
- - ~>
|
@@ -63,8 +67,7 @@ dependencies:
|
|
63
67
|
- 0
|
64
68
|
- 6
|
65
69
|
version: "0.6"
|
66
|
-
|
67
|
-
version_requirements: *id003
|
70
|
+
requirement: *id003
|
68
71
|
description: A toolkit for building modeling frameworks like Active Record and Active Resource. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.
|
69
72
|
email: david@loudthinking.com
|
70
73
|
executables: []
|
@@ -74,45 +77,44 @@ extensions: []
|
|
74
77
|
extra_rdoc_files: []
|
75
78
|
|
76
79
|
files:
|
77
|
-
- CHANGELOG
|
80
|
+
- CHANGELOG.md
|
78
81
|
- MIT-LICENSE
|
79
82
|
- README.rdoc
|
80
|
-
- lib/active_model
|
81
|
-
- lib/active_model/
|
83
|
+
- lib/active_model.rb
|
84
|
+
- lib/active_model/mass_assignment_security.rb
|
85
|
+
- lib/active_model/locale/en.yml
|
82
86
|
- lib/active_model/conversion.rb
|
87
|
+
- lib/active_model/attribute_methods.rb
|
83
88
|
- lib/active_model/dirty.rb
|
84
|
-
- lib/active_model/errors.rb
|
85
|
-
- lib/active_model/lint.rb
|
86
|
-
- lib/active_model/locale/en.yml
|
87
|
-
- lib/active_model/mass_assignment_security/permission_set.rb
|
88
89
|
- lib/active_model/mass_assignment_security/sanitizer.rb
|
89
|
-
- lib/active_model/mass_assignment_security.rb
|
90
|
-
- lib/active_model/
|
90
|
+
- lib/active_model/mass_assignment_security/permission_set.rb
|
91
|
+
- lib/active_model/errors.rb
|
92
|
+
- lib/active_model/test_case.rb
|
91
93
|
- lib/active_model/observer_array.rb
|
94
|
+
- lib/active_model/lint.rb
|
92
95
|
- lib/active_model/observing.rb
|
96
|
+
- lib/active_model/version.rb
|
97
|
+
- lib/active_model/serialization.rb
|
98
|
+
- lib/active_model/naming.rb
|
93
99
|
- lib/active_model/railtie.rb
|
94
100
|
- lib/active_model/secure_password.rb
|
95
|
-
- lib/active_model/serialization.rb
|
96
|
-
- lib/active_model/serializers/json.rb
|
97
|
-
- lib/active_model/serializers/xml.rb
|
98
|
-
- lib/active_model/test_case.rb
|
99
101
|
- lib/active_model/translation.rb
|
100
|
-
- lib/active_model/validations
|
101
|
-
- lib/active_model/
|
102
|
-
- lib/active_model/
|
102
|
+
- lib/active_model/validations.rb
|
103
|
+
- lib/active_model/callbacks.rb
|
104
|
+
- lib/active_model/validator.rb
|
105
|
+
- lib/active_model/validations/validates.rb
|
103
106
|
- lib/active_model/validations/exclusion.rb
|
107
|
+
- lib/active_model/validations/confirmation.rb
|
108
|
+
- lib/active_model/validations/numericality.rb
|
109
|
+
- lib/active_model/validations/acceptance.rb
|
110
|
+
- lib/active_model/validations/with.rb
|
104
111
|
- lib/active_model/validations/format.rb
|
112
|
+
- lib/active_model/validations/callbacks.rb
|
105
113
|
- lib/active_model/validations/inclusion.rb
|
106
114
|
- lib/active_model/validations/length.rb
|
107
|
-
- lib/active_model/validations/numericality.rb
|
108
115
|
- lib/active_model/validations/presence.rb
|
109
|
-
- lib/active_model/
|
110
|
-
- lib/active_model/
|
111
|
-
- lib/active_model/validations.rb
|
112
|
-
- lib/active_model/validator.rb
|
113
|
-
- lib/active_model/version.rb
|
114
|
-
- lib/active_model.rb
|
115
|
-
has_rdoc: true
|
116
|
+
- lib/active_model/serializers/xml.rb
|
117
|
+
- lib/active_model/serializers/json.rb
|
116
118
|
homepage: http://www.rubyonrails.org
|
117
119
|
licenses: []
|
118
120
|
|
@@ -135,16 +137,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
138
|
none: false
|
137
139
|
requirements:
|
138
|
-
- - "
|
140
|
+
- - ">"
|
139
141
|
- !ruby/object:Gem::Version
|
140
|
-
hash:
|
142
|
+
hash: 25
|
141
143
|
segments:
|
142
|
-
-
|
143
|
-
|
144
|
+
- 1
|
145
|
+
- 3
|
146
|
+
- 1
|
147
|
+
version: 1.3.1
|
144
148
|
requirements: []
|
145
149
|
|
146
150
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.
|
151
|
+
rubygems_version: 1.8.6
|
148
152
|
signing_key:
|
149
153
|
specification_version: 3
|
150
154
|
summary: A toolkit for building modeling frameworks (part of Rails).
|
data/CHANGELOG
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
*Rails 3.1.1 (unreleased)*
|
2
|
-
|
3
|
-
* Remove hard dependency on bcrypt-ruby to avoid make ActiveModel dependent on a binary library.
|
4
|
-
You must add the gem explicitly to your Gemfile if you want use ActiveModel::SecurePassword:
|
5
|
-
|
6
|
-
gem 'bcrypt-ruby', '~> 3.0.0'
|
7
|
-
|
8
|
-
See GH #2687. [Guillermo Iguaran]
|
9
|
-
|
10
|
-
*Rails 3.1.0 (August 30, 2011)*
|
11
|
-
|
12
|
-
* Alternate I18n namespace lookup is no longer supported.
|
13
|
-
Instead of "activerecord.models.admins.post", do "activerecord.models.admins/post" instead [José Valim]
|
14
|
-
|
15
|
-
* attr_accessible and friends now accepts :as as option to specify a role [Josh Kalderimis]
|
16
|
-
|
17
|
-
* Add support for proc or lambda as an option for InclusionValidator,
|
18
|
-
ExclusionValidator, and FormatValidator [Prem Sichanugrist]
|
19
|
-
|
20
|
-
You can now supply Proc, lambda, or anything that respond to #call in those
|
21
|
-
validations, and it will be called with current record as an argument.
|
22
|
-
That given proc or lambda must returns an object which respond to #include? for
|
23
|
-
InclusionValidator and ExclusionValidator, and returns a regular expression
|
24
|
-
object for FormatValidator.
|
25
|
-
|
26
|
-
* Added ActiveModel::SecurePassword to encapsulate dead-simple password usage with BCrypt encryption and salting [DHH]
|
27
|
-
|
28
|
-
* ActiveModel::AttributeMethods allows attributes to be defined on demand [Alexander Uvarov]
|
29
|
-
|
30
|
-
* Add support for selectively enabling/disabling observers [Myron Marston]
|
31
|
-
|
32
|
-
|
33
|
-
*Rails 3.0.7 (April 18, 2011)*
|
34
|
-
|
35
|
-
*No changes.
|
36
|
-
|
37
|
-
|
38
|
-
*Rails 3.0.6 (April 5, 2011)
|
39
|
-
|
40
|
-
* Fix when database column name has some symbolic characters (e.g. Oracle CASE# VARCHAR2(20)) #5818 #6850 [Robert Pankowecki, Santiago Pastorino]
|
41
|
-
|
42
|
-
* Fix length validation for fixnums #6556 [Andriy Tyurnikov]
|
43
|
-
|
44
|
-
* Fix i18n key collision with namespaced models #6448 [yves.senn]
|
45
|
-
|
46
|
-
|
47
|
-
*Rails 3.0.5 (February 26, 2011)*
|
48
|
-
|
49
|
-
* No changes.
|
50
|
-
|
51
|
-
|
52
|
-
*Rails 3.0.4 (February 8, 2011)*
|
53
|
-
|
54
|
-
* No changes.
|
55
|
-
|
56
|
-
|
57
|
-
*Rails 3.0.3 (November 16, 2010)*
|
58
|
-
|
59
|
-
* No changes.
|
60
|
-
|
61
|
-
|
62
|
-
*Rails 3.0.2 (November 15, 2010)*
|
63
|
-
|
64
|
-
* No changes
|
65
|
-
|
66
|
-
|
67
|
-
*Rails 3.0.1 (October 15, 2010)*
|
68
|
-
|
69
|
-
* No Changes, just a version bump.
|
70
|
-
|
71
|
-
|
72
|
-
*Rails 3.0.0 (August 29, 2010)*
|
73
|
-
|
74
|
-
* Added ActiveModel::MassAssignmentSecurity [Eric Chapweske, Josh Kalderimis]
|
75
|
-
|
76
|
-
* JSON supports a custom root option: to_json(:root => 'custom') #4515 [Jatinder Singh]
|
77
|
-
|
78
|
-
* #new_record? and #destroyed? were removed from ActiveModel::Lint. Use
|
79
|
-
persisted? instead. A model is persisted if it's not a new_record? and it was
|
80
|
-
not destroyed? [MG]
|
81
|
-
|
82
|
-
* Added validations reflection in ActiveModel::Validations [JV]
|
83
|
-
|
84
|
-
Model.validators
|
85
|
-
Model.validators_on(:field)
|
86
|
-
|
87
|
-
* #to_key was added to ActiveModel::Lint so we can generate DOM IDs for
|
88
|
-
AMo objects with composite keys [MG]
|
89
|
-
|
90
|
-
* ActiveModel::Observer#add_observer!
|
91
|
-
|
92
|
-
It has a custom hook to define after_find that should really be in a
|
93
|
-
ActiveRecord::Observer subclass:
|
94
|
-
|
95
|
-
def add_observer!(klass)
|
96
|
-
klass.add_observer(self)
|
97
|
-
klass.class_eval 'def after_find() end' unless klass.respond_to?(:after_find)
|
98
|
-
end
|
99
|
-
|
100
|
-
* Change the ActiveModel::Base.include_root_in_json default to true for Rails 3 [DHH]
|
101
|
-
|
102
|
-
* Add validates_format_of :without => /regexp/ option. #430 [Elliot Winkler, Peer Allan]
|
103
|
-
|
104
|
-
Example :
|
105
|
-
|
106
|
-
validates_format_of :subdomain, :without => /www|admin|mail/
|
107
|
-
|
108
|
-
* Introduce validates_with to encapsulate attribute validations in a class. #2630 [Jeff Dean]
|
109
|
-
|
110
|
-
* Extracted from Active Record and Active Resource.
|