activemodel 5.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +114 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +264 -0
- data/lib/active_model.rb +77 -0
- data/lib/active_model/attribute.rb +248 -0
- data/lib/active_model/attribute/user_provided_default.rb +52 -0
- data/lib/active_model/attribute_assignment.rb +57 -0
- data/lib/active_model/attribute_methods.rb +478 -0
- data/lib/active_model/attribute_mutation_tracker.rb +124 -0
- data/lib/active_model/attribute_set.rb +114 -0
- data/lib/active_model/attribute_set/builder.rb +126 -0
- data/lib/active_model/attribute_set/yaml_encoder.rb +41 -0
- data/lib/active_model/attributes.rb +111 -0
- data/lib/active_model/callbacks.rb +153 -0
- data/lib/active_model/conversion.rb +111 -0
- data/lib/active_model/dirty.rb +343 -0
- data/lib/active_model/errors.rb +517 -0
- data/lib/active_model/forbidden_attributes_protection.rb +31 -0
- data/lib/active_model/gem_version.rb +17 -0
- data/lib/active_model/lint.rb +118 -0
- data/lib/active_model/locale/en.yml +36 -0
- data/lib/active_model/model.rb +99 -0
- data/lib/active_model/naming.rb +318 -0
- data/lib/active_model/railtie.rb +14 -0
- data/lib/active_model/secure_password.rb +129 -0
- data/lib/active_model/serialization.rb +192 -0
- data/lib/active_model/serializers/json.rb +146 -0
- data/lib/active_model/translation.rb +70 -0
- data/lib/active_model/type.rb +53 -0
- data/lib/active_model/type/big_integer.rb +15 -0
- data/lib/active_model/type/binary.rb +52 -0
- data/lib/active_model/type/boolean.rb +38 -0
- data/lib/active_model/type/date.rb +57 -0
- data/lib/active_model/type/date_time.rb +51 -0
- data/lib/active_model/type/decimal.rb +70 -0
- data/lib/active_model/type/float.rb +36 -0
- data/lib/active_model/type/helpers.rb +7 -0
- data/lib/active_model/type/helpers/accepts_multiparameter_time.rb +41 -0
- data/lib/active_model/type/helpers/mutable.rb +20 -0
- data/lib/active_model/type/helpers/numeric.rb +37 -0
- data/lib/active_model/type/helpers/time_value.rb +68 -0
- data/lib/active_model/type/helpers/timezone.rb +19 -0
- data/lib/active_model/type/immutable_string.rb +32 -0
- data/lib/active_model/type/integer.rb +70 -0
- data/lib/active_model/type/registry.rb +70 -0
- data/lib/active_model/type/string.rb +26 -0
- data/lib/active_model/type/time.rb +51 -0
- data/lib/active_model/type/value.rb +126 -0
- data/lib/active_model/validations.rb +439 -0
- data/lib/active_model/validations/absence.rb +33 -0
- data/lib/active_model/validations/acceptance.rb +106 -0
- data/lib/active_model/validations/callbacks.rb +122 -0
- data/lib/active_model/validations/clusivity.rb +54 -0
- data/lib/active_model/validations/confirmation.rb +80 -0
- data/lib/active_model/validations/exclusion.rb +49 -0
- data/lib/active_model/validations/format.rb +114 -0
- data/lib/active_model/validations/helper_methods.rb +15 -0
- data/lib/active_model/validations/inclusion.rb +47 -0
- data/lib/active_model/validations/length.rb +129 -0
- data/lib/active_model/validations/numericality.rb +189 -0
- data/lib/active_model/validations/presence.rb +39 -0
- data/lib/active_model/validations/validates.rb +174 -0
- data/lib/active_model/validations/with.rb +147 -0
- data/lib/active_model/validator.rb +183 -0
- data/lib/active_model/version.rb +10 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b7a48a8632cd04a47cb21f650b4fff342c211176eec7e4e6fcc2baa0afd05a5
|
4
|
+
data.tar.gz: 170909099c8c1cd1fb72bbb9763dbba6356079c19b2a13511891f092b1045a4b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d27c5bc840d55391b7e7388372a75216aeb3de80f896c35db3fdb681f231755be985d1c8504c5fb5dd5a08d465bf36ecef3318da5c796e1736217117498cd808
|
7
|
+
data.tar.gz: e6315cbe00493bf2d109f307dc86df73f157e4cc1c0869443409c3d428736033d0ee40722dd95750035969bafcc63cb4ea609785538afa99bbd5af7ad8cd96ad
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
## Rails 5.2.3 (March 27, 2019) ##
|
2
|
+
|
3
|
+
* Fix date value when casting a multiparameter date hash to not convert
|
4
|
+
from Gregorian date to Julian date.
|
5
|
+
|
6
|
+
Before:
|
7
|
+
|
8
|
+
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"})
|
9
|
+
=> #<Day id: nil, day: "0001-01-03", created_at: nil, updated_at: nil>
|
10
|
+
|
11
|
+
After:
|
12
|
+
|
13
|
+
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"})
|
14
|
+
=> #<Day id: nil, day: "0001-01-01", created_at: nil, updated_at: nil>
|
15
|
+
|
16
|
+
Fixes #28521.
|
17
|
+
|
18
|
+
*Sayan Chakraborty*
|
19
|
+
|
20
|
+
* Fix numericality equality validation of `BigDecimal` and `Float`
|
21
|
+
by casting to `BigDecimal` on both ends of the validation.
|
22
|
+
|
23
|
+
*Gannon McGibbon*
|
24
|
+
|
25
|
+
|
26
|
+
## Rails 5.2.2.1 (March 11, 2019) ##
|
27
|
+
|
28
|
+
* No changes.
|
29
|
+
|
30
|
+
|
31
|
+
## Rails 5.2.2 (December 04, 2018) ##
|
32
|
+
|
33
|
+
* Fix numericality validator to still use value before type cast except Active Record.
|
34
|
+
|
35
|
+
Fixes #33651, #33686.
|
36
|
+
|
37
|
+
*Ryuta Kamizono*
|
38
|
+
|
39
|
+
|
40
|
+
## Rails 5.2.1.1 (November 27, 2018) ##
|
41
|
+
|
42
|
+
* No changes.
|
43
|
+
|
44
|
+
|
45
|
+
## Rails 5.2.1 (August 07, 2018) ##
|
46
|
+
|
47
|
+
* No changes.
|
48
|
+
|
49
|
+
|
50
|
+
## Rails 5.2.0 (April 09, 2018) ##
|
51
|
+
|
52
|
+
* Do not lose all multiple `:includes` with options in serialization.
|
53
|
+
|
54
|
+
*Mike Mangino*
|
55
|
+
|
56
|
+
* Models using the attributes API with a proc default can now be marshalled.
|
57
|
+
|
58
|
+
Fixes #31216.
|
59
|
+
|
60
|
+
*Sean Griffin*
|
61
|
+
|
62
|
+
* Fix to working before/after validation callbacks on multiple contexts.
|
63
|
+
|
64
|
+
*Yoshiyuki Hirano*
|
65
|
+
|
66
|
+
* Execute `ConfirmationValidator` validation when `_confirmation`'s value is `false`.
|
67
|
+
|
68
|
+
*bogdanvlviv*
|
69
|
+
|
70
|
+
* Allow passing a Proc or Symbol to length validator options.
|
71
|
+
|
72
|
+
*Matt Rohrer*
|
73
|
+
|
74
|
+
* Add method `#merge!` for `ActiveModel::Errors`.
|
75
|
+
|
76
|
+
*Jahfer Husain*
|
77
|
+
|
78
|
+
* Fix regression in numericality validator when comparing Decimal and Float input
|
79
|
+
values with more scale than the schema.
|
80
|
+
|
81
|
+
*Bradley Priest*
|
82
|
+
|
83
|
+
* Fix methods `#keys`, `#values` in `ActiveModel::Errors`.
|
84
|
+
|
85
|
+
Change `#keys` to only return the keys that don't have empty messages.
|
86
|
+
|
87
|
+
Change `#values` to only return the not empty values.
|
88
|
+
|
89
|
+
Example:
|
90
|
+
|
91
|
+
# Before
|
92
|
+
person = Person.new
|
93
|
+
person.errors.keys # => []
|
94
|
+
person.errors.values # => []
|
95
|
+
person.errors.messages # => {}
|
96
|
+
person.errors[:name] # => []
|
97
|
+
person.errors.messages # => {:name => []}
|
98
|
+
person.errors.keys # => [:name]
|
99
|
+
person.errors.values # => [[]]
|
100
|
+
|
101
|
+
# After
|
102
|
+
person = Person.new
|
103
|
+
person.errors.keys # => []
|
104
|
+
person.errors.values # => []
|
105
|
+
person.errors.messages # => {}
|
106
|
+
person.errors[:name] # => []
|
107
|
+
person.errors.messages # => {:name => []}
|
108
|
+
person.errors.keys # => []
|
109
|
+
person.errors.values # => []
|
110
|
+
|
111
|
+
*bogdanvlviv*
|
112
|
+
|
113
|
+
|
114
|
+
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activemodel/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2004-2018 David Heinemeier Hansson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
= Active Model -- model interfaces for Rails
|
2
|
+
|
3
|
+
Active Model provides a known set of interfaces for usage in model classes.
|
4
|
+
They allow for Action Pack helpers to interact with non-Active Record models,
|
5
|
+
for example. Active Model also helps with building custom ORMs for use outside of
|
6
|
+
the Rails framework.
|
7
|
+
|
8
|
+
Prior to Rails 3.0, if a plugin or gem developer wanted to have an object
|
9
|
+
interact with Action Pack helpers, it was required to either copy chunks of
|
10
|
+
code from Rails, or monkey patch entire helpers to make them handle objects
|
11
|
+
that did not exactly conform to the Active Record interface. This would result
|
12
|
+
in code duplication and fragile applications that broke on upgrades. Active
|
13
|
+
Model solves this by defining an explicit API. You can read more about the
|
14
|
+
API in <tt>ActiveModel::Lint::Tests</tt>.
|
15
|
+
|
16
|
+
Active Model provides a default module that implements the basic API required
|
17
|
+
to integrate with Action Pack out of the box: <tt>ActiveModel::Model</tt>.
|
18
|
+
|
19
|
+
class Person
|
20
|
+
include ActiveModel::Model
|
21
|
+
|
22
|
+
attr_accessor :name, :age
|
23
|
+
validates_presence_of :name
|
24
|
+
end
|
25
|
+
|
26
|
+
person = Person.new(name: 'bob', age: '18')
|
27
|
+
person.name # => 'bob'
|
28
|
+
person.age # => '18'
|
29
|
+
person.valid? # => true
|
30
|
+
|
31
|
+
It includes model name introspections, conversions, translations and
|
32
|
+
validations, resulting in a class suitable to be used with Action Pack.
|
33
|
+
See <tt>ActiveModel::Model</tt> for more examples.
|
34
|
+
|
35
|
+
Active Model also provides the following functionality to have ORM-like
|
36
|
+
behavior out of the box:
|
37
|
+
|
38
|
+
* Add attribute magic to objects
|
39
|
+
|
40
|
+
class Person
|
41
|
+
include ActiveModel::AttributeMethods
|
42
|
+
|
43
|
+
attribute_method_prefix 'clear_'
|
44
|
+
define_attribute_methods :name, :age
|
45
|
+
|
46
|
+
attr_accessor :name, :age
|
47
|
+
|
48
|
+
def clear_attribute(attr)
|
49
|
+
send("#{attr}=", nil)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
person = Person.new
|
54
|
+
person.clear_name
|
55
|
+
person.clear_age
|
56
|
+
|
57
|
+
{Learn more}[link:classes/ActiveModel/AttributeMethods.html]
|
58
|
+
|
59
|
+
* Callbacks for certain operations
|
60
|
+
|
61
|
+
class Person
|
62
|
+
extend ActiveModel::Callbacks
|
63
|
+
define_model_callbacks :create
|
64
|
+
|
65
|
+
def create
|
66
|
+
run_callbacks :create do
|
67
|
+
# Your create action methods here
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
This generates +before_create+, +around_create+ and +after_create+
|
73
|
+
class methods that wrap your create method.
|
74
|
+
|
75
|
+
{Learn more}[link:classes/ActiveModel/Callbacks.html]
|
76
|
+
|
77
|
+
* Tracking value changes
|
78
|
+
|
79
|
+
class Person
|
80
|
+
include ActiveModel::Dirty
|
81
|
+
|
82
|
+
define_attribute_methods :name
|
83
|
+
|
84
|
+
def name
|
85
|
+
@name
|
86
|
+
end
|
87
|
+
|
88
|
+
def name=(val)
|
89
|
+
name_will_change! unless val == @name
|
90
|
+
@name = val
|
91
|
+
end
|
92
|
+
|
93
|
+
def save
|
94
|
+
# do persistence work
|
95
|
+
changes_applied
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
person = Person.new
|
100
|
+
person.name # => nil
|
101
|
+
person.changed? # => false
|
102
|
+
person.name = 'bob'
|
103
|
+
person.changed? # => true
|
104
|
+
person.changed # => ['name']
|
105
|
+
person.changes # => { 'name' => [nil, 'bob'] }
|
106
|
+
person.save
|
107
|
+
person.name = 'robert'
|
108
|
+
person.save
|
109
|
+
person.previous_changes # => {'name' => ['bob, 'robert']}
|
110
|
+
|
111
|
+
{Learn more}[link:classes/ActiveModel/Dirty.html]
|
112
|
+
|
113
|
+
* Adding +errors+ interface to objects
|
114
|
+
|
115
|
+
Exposing error messages allows objects to interact with Action Pack
|
116
|
+
helpers seamlessly.
|
117
|
+
|
118
|
+
class Person
|
119
|
+
|
120
|
+
def initialize
|
121
|
+
@errors = ActiveModel::Errors.new(self)
|
122
|
+
end
|
123
|
+
|
124
|
+
attr_accessor :name
|
125
|
+
attr_reader :errors
|
126
|
+
|
127
|
+
def validate!
|
128
|
+
errors.add(:name, "cannot be nil") if name.nil?
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.human_attribute_name(attr, options = {})
|
132
|
+
"Name"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
person = Person.new
|
137
|
+
person.name = nil
|
138
|
+
person.validate!
|
139
|
+
person.errors.full_messages
|
140
|
+
# => ["Name cannot be nil"]
|
141
|
+
|
142
|
+
{Learn more}[link:classes/ActiveModel/Errors.html]
|
143
|
+
|
144
|
+
* Model name introspection
|
145
|
+
|
146
|
+
class NamedPerson
|
147
|
+
extend ActiveModel::Naming
|
148
|
+
end
|
149
|
+
|
150
|
+
NamedPerson.model_name.name # => "NamedPerson"
|
151
|
+
NamedPerson.model_name.human # => "Named person"
|
152
|
+
|
153
|
+
{Learn more}[link:classes/ActiveModel/Naming.html]
|
154
|
+
|
155
|
+
* Making objects serializable
|
156
|
+
|
157
|
+
<tt>ActiveModel::Serialization</tt> provides a standard interface for your object
|
158
|
+
to provide +to_json+ serialization.
|
159
|
+
|
160
|
+
class SerialPerson
|
161
|
+
include ActiveModel::Serialization
|
162
|
+
|
163
|
+
attr_accessor :name
|
164
|
+
|
165
|
+
def attributes
|
166
|
+
{'name' => name}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
s = SerialPerson.new
|
171
|
+
s.serializable_hash # => {"name"=>nil}
|
172
|
+
|
173
|
+
class SerialPerson
|
174
|
+
include ActiveModel::Serializers::JSON
|
175
|
+
end
|
176
|
+
|
177
|
+
s = SerialPerson.new
|
178
|
+
s.to_json # => "{\"name\":null}"
|
179
|
+
|
180
|
+
{Learn more}[link:classes/ActiveModel/Serialization.html]
|
181
|
+
|
182
|
+
* Internationalization (i18n) support
|
183
|
+
|
184
|
+
class Person
|
185
|
+
extend ActiveModel::Translation
|
186
|
+
end
|
187
|
+
|
188
|
+
Person.human_attribute_name('my_attribute')
|
189
|
+
# => "My attribute"
|
190
|
+
|
191
|
+
{Learn more}[link:classes/ActiveModel/Translation.html]
|
192
|
+
|
193
|
+
* Validation support
|
194
|
+
|
195
|
+
class Person
|
196
|
+
include ActiveModel::Validations
|
197
|
+
|
198
|
+
attr_accessor :first_name, :last_name
|
199
|
+
|
200
|
+
validates_each :first_name, :last_name do |record, attr, value|
|
201
|
+
record.errors.add attr, 'starts with z.' if value.to_s[0] == ?z
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
person = Person.new
|
206
|
+
person.first_name = 'zoolander'
|
207
|
+
person.valid? # => false
|
208
|
+
|
209
|
+
{Learn more}[link:classes/ActiveModel/Validations.html]
|
210
|
+
|
211
|
+
* Custom validators
|
212
|
+
|
213
|
+
class HasNameValidator < ActiveModel::Validator
|
214
|
+
def validate(record)
|
215
|
+
record.errors.add(:name, "must exist") if record.name.blank?
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
class ValidatorPerson
|
220
|
+
include ActiveModel::Validations
|
221
|
+
validates_with HasNameValidator
|
222
|
+
attr_accessor :name
|
223
|
+
end
|
224
|
+
|
225
|
+
p = ValidatorPerson.new
|
226
|
+
p.valid? # => false
|
227
|
+
p.errors.full_messages # => ["Name must exist"]
|
228
|
+
p.name = "Bob"
|
229
|
+
p.valid? # => true
|
230
|
+
|
231
|
+
{Learn more}[link:classes/ActiveModel/Validator.html]
|
232
|
+
|
233
|
+
|
234
|
+
== Download and installation
|
235
|
+
|
236
|
+
The latest version of Active Model can be installed with RubyGems:
|
237
|
+
|
238
|
+
$ gem install activemodel
|
239
|
+
|
240
|
+
Source code can be downloaded as part of the Rails project on GitHub
|
241
|
+
|
242
|
+
* https://github.com/rails/rails/tree/5-2-stable/activemodel
|
243
|
+
|
244
|
+
|
245
|
+
== License
|
246
|
+
|
247
|
+
Active Model is released under the MIT license:
|
248
|
+
|
249
|
+
* https://opensource.org/licenses/MIT
|
250
|
+
|
251
|
+
|
252
|
+
== Support
|
253
|
+
|
254
|
+
API documentation is at:
|
255
|
+
|
256
|
+
* http://api.rubyonrails.org
|
257
|
+
|
258
|
+
Bug reports for the Ruby on Rails project can be filed here:
|
259
|
+
|
260
|
+
* https://github.com/rails/rails/issues
|
261
|
+
|
262
|
+
Feature requests should be discussed on the rails-core mailing list here:
|
263
|
+
|
264
|
+
* https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
|
data/lib/active_model.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2004-2018 David Heinemeier Hansson
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
require "active_support"
|
27
|
+
require "active_support/rails"
|
28
|
+
require "active_model/version"
|
29
|
+
|
30
|
+
module ActiveModel
|
31
|
+
extend ActiveSupport::Autoload
|
32
|
+
|
33
|
+
autoload :Attribute
|
34
|
+
autoload :Attributes
|
35
|
+
autoload :AttributeAssignment
|
36
|
+
autoload :AttributeMethods
|
37
|
+
autoload :BlockValidator, "active_model/validator"
|
38
|
+
autoload :Callbacks
|
39
|
+
autoload :Conversion
|
40
|
+
autoload :Dirty
|
41
|
+
autoload :EachValidator, "active_model/validator"
|
42
|
+
autoload :ForbiddenAttributesProtection
|
43
|
+
autoload :Lint
|
44
|
+
autoload :Model
|
45
|
+
autoload :Name, "active_model/naming"
|
46
|
+
autoload :Naming
|
47
|
+
autoload :SecurePassword
|
48
|
+
autoload :Serialization
|
49
|
+
autoload :Translation
|
50
|
+
autoload :Type
|
51
|
+
autoload :Validations
|
52
|
+
autoload :Validator
|
53
|
+
|
54
|
+
eager_autoload do
|
55
|
+
autoload :Errors
|
56
|
+
autoload :RangeError, "active_model/errors"
|
57
|
+
autoload :StrictValidationFailed, "active_model/errors"
|
58
|
+
autoload :UnknownAttributeError, "active_model/errors"
|
59
|
+
end
|
60
|
+
|
61
|
+
module Serializers
|
62
|
+
extend ActiveSupport::Autoload
|
63
|
+
|
64
|
+
eager_autoload do
|
65
|
+
autoload :JSON
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.eager_load!
|
70
|
+
super
|
71
|
+
ActiveModel::Serializers.eager_load!
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
ActiveSupport.on_load(:i18n) do
|
76
|
+
I18n.load_path << File.expand_path("active_model/locale/en.yml", __dir__)
|
77
|
+
end
|