activemodel 4.2.0 → 4.2.11
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 +5 -5
- data/CHANGELOG.md +67 -0
- data/lib/active_model/dirty.rb +23 -14
- data/lib/active_model/gem_version.rb +1 -1
- data/lib/active_model/naming.rb +3 -2
- data/lib/active_model/serializers/json.rb +1 -1
- data/lib/active_model/validations.rb +6 -2
- data/lib/active_model/validations/numericality.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d819fe3f01d5eb8c4d55a61586461791d88ad1d66156cf4e320d0d4e7cf02d7
|
4
|
+
data.tar.gz: adce50103ae18991d15f7f3532d610ee5c608c8be471e41c519feb5f88ae75d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40dea169cec02dc81fa05cb5e257c165f9c42293464fe1344811efaac7c2544edbdc9092d08cef52fb3d4b1fd4f555f97f72dd1afcae6d05f1aab0952ad4d30
|
7
|
+
data.tar.gz: 6b3accb008d16311d339d304cd373dafa9758ae9039959c9b2f4caadccf760125ac667c5baad2876850efff27ac6debed4c405b2350fa9d56229aaf9da0216df
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,70 @@
|
|
1
|
+
## Rails 4.2.11 (November 27, 2018) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 4.2.10 (September 27, 2017) ##
|
7
|
+
|
8
|
+
* No changes.
|
9
|
+
|
10
|
+
|
11
|
+
## Rails 4.2.9 (June 26, 2017) ##
|
12
|
+
|
13
|
+
* No changes.
|
14
|
+
|
15
|
+
|
16
|
+
## Rails 4.2.8 (February 21, 2017) ##
|
17
|
+
|
18
|
+
* No changes.
|
19
|
+
|
20
|
+
|
21
|
+
## Rails 4.2.7 (July 12, 2016) ##
|
22
|
+
|
23
|
+
* No changes.
|
24
|
+
|
25
|
+
|
26
|
+
## Rails 4.2.6 (March 07, 2016) ##
|
27
|
+
|
28
|
+
* No changes.
|
29
|
+
|
30
|
+
|
31
|
+
## Rails 4.2.5.2 (February 26, 2016) ##
|
32
|
+
|
33
|
+
* No changes.
|
34
|
+
|
35
|
+
|
36
|
+
## Rails 4.2.5.1 (January 25, 2015) ##
|
37
|
+
|
38
|
+
* No changes.
|
39
|
+
|
40
|
+
|
41
|
+
## Rails 4.2.5 (November 12, 2015) ##
|
42
|
+
|
43
|
+
* No changes.
|
44
|
+
|
45
|
+
|
46
|
+
## Rails 4.2.4 (August 24, 2015) ##
|
47
|
+
|
48
|
+
* No Changes *
|
49
|
+
|
50
|
+
|
51
|
+
## Rails 4.2.3 (June 25, 2015) ##
|
52
|
+
|
53
|
+
* No Changes *
|
54
|
+
|
55
|
+
|
56
|
+
## Rails 4.2.2 (June 16, 2015) ##
|
57
|
+
|
58
|
+
* No Changes *
|
59
|
+
|
60
|
+
|
61
|
+
## Rails 4.2.1 (March 19, 2015) ##
|
62
|
+
|
63
|
+
* No changes.
|
64
|
+
|
65
|
+
|
66
|
+
## Rails 4.2.0 (December 20, 2014) ##
|
67
|
+
|
1
68
|
* Passwords with spaces only allowed in `ActiveModel::SecurePassword`.
|
2
69
|
|
3
70
|
Presence validation can be used to restore old behavior.
|
data/lib/active_model/dirty.rb
CHANGED
@@ -27,6 +27,10 @@ module ActiveModel
|
|
27
27
|
#
|
28
28
|
# define_attribute_methods :name
|
29
29
|
#
|
30
|
+
# def initialize(name)
|
31
|
+
# @name = name
|
32
|
+
# end
|
33
|
+
#
|
30
34
|
# def name
|
31
35
|
# @name
|
32
36
|
# end
|
@@ -53,10 +57,10 @@ module ActiveModel
|
|
53
57
|
# end
|
54
58
|
# end
|
55
59
|
#
|
56
|
-
# A newly instantiated object is unchanged:
|
60
|
+
# A newly instantiated +Person+ object is unchanged:
|
57
61
|
#
|
58
|
-
# person = Person.
|
59
|
-
# person.changed?
|
62
|
+
# person = Person.new("Uncle Bob")
|
63
|
+
# person.changed? # => false
|
60
64
|
#
|
61
65
|
# Change the name:
|
62
66
|
#
|
@@ -72,8 +76,8 @@ module ActiveModel
|
|
72
76
|
# Save the changes:
|
73
77
|
#
|
74
78
|
# person.save
|
75
|
-
# person.changed?
|
76
|
-
# person.name_changed?
|
79
|
+
# person.changed? # => false
|
80
|
+
# person.name_changed? # => false
|
77
81
|
#
|
78
82
|
# Reset the changes:
|
79
83
|
#
|
@@ -85,20 +89,20 @@ module ActiveModel
|
|
85
89
|
#
|
86
90
|
# person.name = "Uncle Bob"
|
87
91
|
# person.rollback!
|
88
|
-
# person.name
|
89
|
-
# person.name_changed?
|
92
|
+
# person.name # => "Bill"
|
93
|
+
# person.name_changed? # => false
|
90
94
|
#
|
91
95
|
# Assigning the same value leaves the attribute unchanged:
|
92
96
|
#
|
93
97
|
# person.name = 'Bill'
|
94
|
-
# person.name_changed?
|
95
|
-
# person.name_change
|
98
|
+
# person.name_changed? # => false
|
99
|
+
# person.name_change # => nil
|
96
100
|
#
|
97
101
|
# Which attributes have changed?
|
98
102
|
#
|
99
103
|
# person.name = 'Bob'
|
100
|
-
# person.changed
|
101
|
-
# person.changes
|
104
|
+
# person.changed # => ["name"]
|
105
|
+
# person.changes # => {"name" => ["Bill", "Bob"]}
|
102
106
|
#
|
103
107
|
# If an attribute is modified in-place then make use of
|
104
108
|
# +[attribute_name]_will_change!+ to mark that the attribute is changing.
|
@@ -107,9 +111,9 @@ module ActiveModel
|
|
107
111
|
# not need to call +[attribute_name]_will_change!+ on Active Record models.
|
108
112
|
#
|
109
113
|
# person.name_will_change!
|
110
|
-
# person.name_change
|
114
|
+
# person.name_change # => ["Bill", "Bill"]
|
111
115
|
# person.name << 'y'
|
112
|
-
# person.name_change
|
116
|
+
# person.name_change # => ["Bill", "Billy"]
|
113
117
|
module Dirty
|
114
118
|
extend ActiveSupport::Concern
|
115
119
|
include ActiveModel::AttributeMethods
|
@@ -170,7 +174,7 @@ module ActiveModel
|
|
170
174
|
|
171
175
|
# Handle <tt>*_changed?</tt> for +method_missing+.
|
172
176
|
def attribute_changed?(attr, options = {}) #:nodoc:
|
173
|
-
result =
|
177
|
+
result = changes_include?(attr)
|
174
178
|
result &&= options[:to] == __send__(attr) if options.key?(:to)
|
175
179
|
result &&= options[:from] == changed_attributes[attr] if options.key?(:from)
|
176
180
|
result
|
@@ -188,6 +192,11 @@ module ActiveModel
|
|
188
192
|
|
189
193
|
private
|
190
194
|
|
195
|
+
def changes_include?(attr_name)
|
196
|
+
attributes_changed_by_setter.include?(attr_name)
|
197
|
+
end
|
198
|
+
alias attribute_changed_by_setter? changes_include?
|
199
|
+
|
191
200
|
# Removes current changes and makes them accessible through +previous_changes+.
|
192
201
|
def changes_applied # :doc:
|
193
202
|
@previously_changed = changes
|
data/lib/active_model/naming.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/hash/except'
|
2
2
|
require 'active_support/core_ext/module/introspection'
|
3
|
+
require 'active_support/core_ext/module/remove_method'
|
3
4
|
|
4
5
|
module ActiveModel
|
5
6
|
class Name
|
@@ -129,7 +130,7 @@ module ActiveModel
|
|
129
130
|
#
|
130
131
|
# Equivalent to +to_s+.
|
131
132
|
delegate :==, :===, :<=>, :=~, :"!~", :eql?, :to_s,
|
132
|
-
:to_str, to: :name
|
133
|
+
:to_str, :as_json, to: :name
|
133
134
|
|
134
135
|
# Returns a new ActiveModel::Name instance. By default, the +namespace+
|
135
136
|
# and +name+ option will take the namespace and name of the given class
|
@@ -224,7 +225,7 @@ module ActiveModel
|
|
224
225
|
# (See ActiveModel::Name for more information).
|
225
226
|
#
|
226
227
|
# class Person
|
227
|
-
#
|
228
|
+
# extend ActiveModel::Naming
|
228
229
|
# end
|
229
230
|
#
|
230
231
|
# Person.model_name.name # => "Person"
|
@@ -47,9 +47,10 @@ module ActiveModel
|
|
47
47
|
include HelperMethods
|
48
48
|
|
49
49
|
attr_accessor :validation_context
|
50
|
+
private :validation_context=
|
50
51
|
define_callbacks :validate, scope: :name
|
51
52
|
|
52
|
-
class_attribute :_validators
|
53
|
+
class_attribute :_validators, instance_writer: false
|
53
54
|
self._validators = Hash.new { |h,k| h[k] = [] }
|
54
55
|
end
|
55
56
|
|
@@ -87,7 +88,7 @@ module ActiveModel
|
|
87
88
|
validates_with BlockValidator, _merge_attributes(attr_names), &block
|
88
89
|
end
|
89
90
|
|
90
|
-
VALID_OPTIONS_FOR_VALIDATE = [:on, :if, :unless, :prepend].freeze
|
91
|
+
VALID_OPTIONS_FOR_VALIDATE = [:on, :if, :unless, :prepend].freeze # :nodoc:
|
91
92
|
|
92
93
|
# Adds a validation method or block to the class. This is useful when
|
93
94
|
# overriding the +validate+ instance method becomes too unwieldy and
|
@@ -129,6 +130,9 @@ module ActiveModel
|
|
129
130
|
# end
|
130
131
|
# end
|
131
132
|
#
|
133
|
+
# Note that the return value of validation methods is not relevant.
|
134
|
+
# It's not possible to halt the validate callback chain.
|
135
|
+
#
|
132
136
|
# Options:
|
133
137
|
# * <tt>:on</tt> - Specifies the contexts where this validation is active.
|
134
138
|
# Runs in all validation contexts by default (nil). You can pass a symbol
|
@@ -114,7 +114,7 @@ module ActiveModel
|
|
114
114
|
# * <tt>:only_integer</tt> - Specifies whether the value has to be an
|
115
115
|
# integer, e.g. an integral value (default is +false+).
|
116
116
|
# * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is
|
117
|
-
# +false+). Notice that for
|
117
|
+
# +false+). Notice that for Integer and Float columns empty strings are
|
118
118
|
# converted to +nil+.
|
119
119
|
# * <tt>:greater_than</tt> - Specifies the value must be greater than the
|
120
120
|
# supplied 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: 4.2.
|
4
|
+
version: 4.2.11
|
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:
|
11
|
+
date: 2018-11-27 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: 4.2.
|
19
|
+
version: 4.2.11
|
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: 4.2.
|
26
|
+
version: 4.2.11
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.7.6
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: A toolkit for building modeling frameworks (part of Rails).
|