activemodel 3.1.0.rc4 → 3.1.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/README.rdoc +27 -0
- data/lib/active_model/dirty.rb +1 -1
- data/lib/active_model/mass_assignment_security.rb +11 -4
- data/lib/active_model/naming.rb +3 -4
- data/lib/active_model/translation.rb +2 -3
- data/lib/active_model/validations/with.rb +2 -2
- data/lib/active_model/version.rb +1 -1
- metadata +9 -22
data/CHANGELOG
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
*Rails 3.1.0 (unreleased)*
|
2
2
|
|
3
|
+
* Alternate I18n namespace lookup is no longer supported.
|
4
|
+
Instead of "activerecord.models.admins.post", do "activerecord.models.admins/post" instead [José Valim]
|
5
|
+
|
3
6
|
* attr_accessible and friends now accepts :as as option to specify a role [Josh Kalderimis]
|
4
7
|
|
5
8
|
* Add support for proc or lambda as an option for InclusionValidator,
|
data/README.rdoc
CHANGED
@@ -182,3 +182,30 @@ modules:
|
|
182
182
|
p.valid? # => true
|
183
183
|
|
184
184
|
{Learn more}[link:classes/ActiveModel/Validator.html]
|
185
|
+
|
186
|
+
|
187
|
+
== Download and installation
|
188
|
+
|
189
|
+
The latest version of Active Model can be installed with Rubygems:
|
190
|
+
|
191
|
+
% [sudo] gem install activemodel
|
192
|
+
|
193
|
+
Source code can be downloaded as part of the Rails project on GitHub
|
194
|
+
|
195
|
+
* https://github.com/rails/rails/tree/master/activemodel/
|
196
|
+
|
197
|
+
|
198
|
+
== License
|
199
|
+
|
200
|
+
Active Model is released under the MIT license.
|
201
|
+
|
202
|
+
|
203
|
+
== Support
|
204
|
+
|
205
|
+
API documentation is at
|
206
|
+
|
207
|
+
* http://api.rubyonrails.org
|
208
|
+
|
209
|
+
Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
|
210
|
+
|
211
|
+
* https://github.com/rails/rails/issues
|
data/lib/active_model/dirty.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute.rb'
|
2
|
+
require 'active_support/core_ext/array/wrap'
|
2
3
|
require 'active_model/mass_assignment_security/permission_set'
|
3
4
|
|
4
5
|
module ActiveModel
|
@@ -95,8 +96,11 @@ module ActiveModel
|
|
95
96
|
options = args.extract_options!
|
96
97
|
role = options[:as] || :default
|
97
98
|
|
98
|
-
self._protected_attributes
|
99
|
-
|
99
|
+
self._protected_attributes = protected_attributes_configs.dup
|
100
|
+
|
101
|
+
Array.wrap(role).each do |name|
|
102
|
+
self._protected_attributes[name] = self.protected_attributes(name) + args
|
103
|
+
end
|
100
104
|
|
101
105
|
self._active_authorizer = self._protected_attributes
|
102
106
|
end
|
@@ -154,8 +158,11 @@ module ActiveModel
|
|
154
158
|
options = args.extract_options!
|
155
159
|
role = options[:as] || :default
|
156
160
|
|
157
|
-
self._accessible_attributes
|
158
|
-
|
161
|
+
self._accessible_attributes = accessible_attributes_configs.dup
|
162
|
+
|
163
|
+
Array.wrap(role).each do |name|
|
164
|
+
self._accessible_attributes[name] = self.accessible_attributes(name) + args
|
165
|
+
end
|
159
166
|
|
160
167
|
self._active_authorizer = self._accessible_attributes
|
161
168
|
end
|
data/lib/active_model/naming.rb
CHANGED
@@ -21,7 +21,7 @@ module ActiveModel
|
|
21
21
|
@partial_path = "#{@collection}/#{@element}".freeze
|
22
22
|
@param_key = (namespace ? _singularize(@unnamespaced) : @singular).freeze
|
23
23
|
@route_key = (namespace ? ActiveSupport::Inflector.pluralize(@param_key) : @plural).freeze
|
24
|
-
@i18n_key = self.underscore.
|
24
|
+
@i18n_key = self.underscore.to_sym
|
25
25
|
end
|
26
26
|
|
27
27
|
# Transform the model name into a more humane format, using I18n. By default,
|
@@ -35,9 +35,8 @@ module ActiveModel
|
|
35
35
|
@klass.respond_to?(:i18n_scope)
|
36
36
|
|
37
37
|
defaults = @klass.lookup_ancestors.map do |klass|
|
38
|
-
|
39
|
-
|
40
|
-
end.flatten
|
38
|
+
klass.model_name.i18n_key
|
39
|
+
end
|
41
40
|
|
42
41
|
defaults << options[:default] if options[:default]
|
43
42
|
defaults << @human
|
@@ -44,9 +44,8 @@ module ActiveModel
|
|
44
44
|
# Specify +options+ with additional translating options.
|
45
45
|
def human_attribute_name(attribute, options = {})
|
46
46
|
defaults = lookup_ancestors.map do |klass|
|
47
|
-
|
48
|
-
|
49
|
-
end.flatten
|
47
|
+
:"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}"
|
48
|
+
end
|
50
49
|
|
51
50
|
defaults << :"attributes.#{attribute}"
|
52
51
|
defaults << options.delete(:default) if options[:default]
|
@@ -101,7 +101,7 @@ module ActiveModel
|
|
101
101
|
# class Person
|
102
102
|
# include ActiveModel::Validations
|
103
103
|
#
|
104
|
-
#
|
104
|
+
# validate :instance_validations
|
105
105
|
#
|
106
106
|
# def instance_validations
|
107
107
|
# validates_with MyValidator
|
@@ -116,7 +116,7 @@ module ActiveModel
|
|
116
116
|
# class Person
|
117
117
|
# include ActiveModel::Validations
|
118
118
|
#
|
119
|
-
#
|
119
|
+
# validate :instance_validations, :on => :create
|
120
120
|
#
|
121
121
|
# def instance_validations
|
122
122
|
# validates_with MyValidator, MyOtherValidator
|
data/lib/active_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: 6
|
4
|
+
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 3
|
8
7
|
- 1
|
9
8
|
- 0
|
10
|
-
-
|
11
|
-
|
12
|
-
version: 3.1.0.rc4
|
9
|
+
- rc5
|
10
|
+
version: 3.1.0.rc5
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- David Heinemeier Hansson
|
@@ -17,35 +15,31 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2011-
|
18
|
+
date: 2011-07-25 00:00:00 -07:00
|
19
|
+
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: activesupport
|
24
23
|
prerelease: false
|
25
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
25
|
requirements:
|
28
26
|
- - "="
|
29
27
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 15424109
|
31
28
|
segments:
|
32
29
|
- 3
|
33
30
|
- 1
|
34
31
|
- 0
|
35
|
-
-
|
36
|
-
|
37
|
-
version: 3.1.0.rc4
|
32
|
+
- rc5
|
33
|
+
version: 3.1.0.rc5
|
38
34
|
type: :runtime
|
39
35
|
version_requirements: *id001
|
40
36
|
- !ruby/object:Gem::Dependency
|
41
37
|
name: builder
|
42
38
|
prerelease: false
|
43
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
40
|
requirements:
|
46
41
|
- - ~>
|
47
42
|
- !ruby/object:Gem::Version
|
48
|
-
hash: 7
|
49
43
|
segments:
|
50
44
|
- 3
|
51
45
|
- 0
|
@@ -57,11 +51,9 @@ dependencies:
|
|
57
51
|
name: i18n
|
58
52
|
prerelease: false
|
59
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
54
|
requirements:
|
62
55
|
- - ~>
|
63
56
|
- !ruby/object:Gem::Version
|
64
|
-
hash: 7
|
65
57
|
segments:
|
66
58
|
- 0
|
67
59
|
- 6
|
@@ -72,11 +64,9 @@ dependencies:
|
|
72
64
|
name: bcrypt-ruby
|
73
65
|
prerelease: false
|
74
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
67
|
requirements:
|
77
68
|
- - ~>
|
78
69
|
- !ruby/object:Gem::Version
|
79
|
-
hash: 3
|
80
70
|
segments:
|
81
71
|
- 2
|
82
72
|
- 1
|
@@ -131,6 +121,7 @@ files:
|
|
131
121
|
- lib/active_model/validator.rb
|
132
122
|
- lib/active_model/version.rb
|
133
123
|
- lib/active_model.rb
|
124
|
+
has_rdoc: true
|
134
125
|
homepage: http://www.rubyonrails.org
|
135
126
|
licenses: []
|
136
127
|
|
@@ -140,22 +131,18 @@ rdoc_options: []
|
|
140
131
|
require_paths:
|
141
132
|
- lib
|
142
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
134
|
requirements:
|
145
135
|
- - ">="
|
146
136
|
- !ruby/object:Gem::Version
|
147
|
-
hash: 57
|
148
137
|
segments:
|
149
138
|
- 1
|
150
139
|
- 8
|
151
140
|
- 7
|
152
141
|
version: 1.8.7
|
153
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
143
|
requirements:
|
156
144
|
- - ">"
|
157
145
|
- !ruby/object:Gem::Version
|
158
|
-
hash: 25
|
159
146
|
segments:
|
160
147
|
- 1
|
161
148
|
- 3
|
@@ -164,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
151
|
requirements: []
|
165
152
|
|
166
153
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.
|
154
|
+
rubygems_version: 1.3.6
|
168
155
|
signing_key:
|
169
156
|
specification_version: 3
|
170
157
|
summary: A toolkit for building modeling frameworks (part of Rails).
|