activemodel 3.0.3 → 3.0.4.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.
@@ -46,8 +46,8 @@ module ActiveModel
|
|
46
46
|
# end
|
47
47
|
# end
|
48
48
|
#
|
49
|
-
#
|
50
|
-
# it requires you to implement
|
49
|
+
# Note that whenever you include ActiveModel::AttributeMethods in your class,
|
50
|
+
# it requires you to implement an <tt>attributes</tt> method which returns a hash
|
51
51
|
# with each attribute name in your model as hash key and the attribute value as
|
52
52
|
# hash value.
|
53
53
|
#
|
data/lib/active_model/errors.rb
CHANGED
@@ -149,7 +149,7 @@ module ActiveModel
|
|
149
149
|
def empty?
|
150
150
|
all? { |k, v| v && v.empty? }
|
151
151
|
end
|
152
|
-
|
152
|
+
alias_method :blank?, :empty?
|
153
153
|
# Returns an xml formatted representation of the Errors hash.
|
154
154
|
#
|
155
155
|
# p.errors.add(:name, "can't be blank")
|
@@ -167,7 +167,13 @@ module ActiveModel
|
|
167
167
|
|
168
168
|
# Returns an ActiveSupport::OrderedHash that can be used as the JSON representation for this object.
|
169
169
|
def as_json(options=nil)
|
170
|
-
|
170
|
+
to_hash
|
171
|
+
end
|
172
|
+
|
173
|
+
def to_hash
|
174
|
+
hash = ActiveSupport::OrderedHash.new
|
175
|
+
each { |k, v| (hash[k] ||= []) << v }
|
176
|
+
hash
|
171
177
|
end
|
172
178
|
|
173
179
|
# Adds +message+ to the error messages on +attribute+, which will be returned on a call to
|
data/lib/active_model/lint.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
# == Active Model Lint Tests
|
2
|
-
#
|
3
|
-
# You can test whether an object is compliant with the Active Model API by
|
4
|
-
# including <tt>ActiveModel::Lint::Tests</tt> in your TestCase. It will include
|
5
|
-
# tests that tell you whether your object is fully compliant, or if not,
|
6
|
-
# which aspects of the API are not implemented.
|
7
|
-
#
|
8
|
-
# These tests do not attempt to determine the semantic correctness of the
|
9
|
-
# returned values. For instance, you could implement valid? to always
|
10
|
-
# return true, and the tests would pass. It is up to you to ensure that
|
11
|
-
# the values are semantically meaningful.
|
12
|
-
#
|
13
|
-
# Objects you pass in are expected to return a compliant object from a
|
14
|
-
# call to to_model. It is perfectly fine for to_model to return self.
|
15
1
|
module ActiveModel
|
16
2
|
module Lint
|
3
|
+
# == Active Model Lint Tests
|
4
|
+
#
|
5
|
+
# You can test whether an object is compliant with the Active Model API by
|
6
|
+
# including <tt>ActiveModel::Lint::Tests</tt> in your TestCase. It will include
|
7
|
+
# tests that tell you whether your object is fully compliant, or if not,
|
8
|
+
# which aspects of the API are not implemented.
|
9
|
+
#
|
10
|
+
# These tests do not attempt to determine the semantic correctness of the
|
11
|
+
# returned values. For instance, you could implement valid? to always
|
12
|
+
# return true, and the tests would pass. It is up to you to ensure that
|
13
|
+
# the values are semantically meaningful.
|
14
|
+
#
|
15
|
+
# Objects you pass in are expected to return a compliant object from a
|
16
|
+
# call to to_model. It is perfectly fine for to_model to return self.
|
17
17
|
module Tests
|
18
18
|
|
19
19
|
# == Responds to <tt>to_key</tt>
|
@@ -17,6 +17,7 @@ module ActiveModel
|
|
17
17
|
|
18
18
|
def initialize(name, serializable, raw_value=nil)
|
19
19
|
@name, @serializable = name, serializable
|
20
|
+
raw_value = raw_value.in_time_zone if raw_value.respond_to?(:in_time_zone)
|
20
21
|
@value = raw_value || @serializable.send(name)
|
21
22
|
@type = compute_type
|
22
23
|
end
|
@@ -103,8 +103,10 @@ module ActiveModel
|
|
103
103
|
{ :with => options }
|
104
104
|
when Range, Array
|
105
105
|
{ :in => options }
|
106
|
+
else
|
107
|
+
raise ArgumentError, "#{options.inspect} is an invalid option. Expecting true, Hash, Regexp, Range, or Array"
|
106
108
|
end
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
110
|
-
end
|
112
|
+
end
|
data/lib/active_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 977940590
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
|
9
|
+
- 4
|
10
|
+
- rc1
|
11
|
+
version: 3.0.4.rc1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- David Heinemeier Hansson
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
+
date: 2011-01-31 00:00:00 +13:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +27,13 @@ dependencies:
|
|
26
27
|
requirements:
|
27
28
|
- - "="
|
28
29
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
30
|
+
hash: 977940590
|
30
31
|
segments:
|
31
32
|
- 3
|
32
33
|
- 0
|
33
|
-
-
|
34
|
-
|
34
|
+
- 4
|
35
|
+
- rc1
|
36
|
+
version: 3.0.4.rc1
|
35
37
|
type: :runtime
|
36
38
|
version_requirements: *id001
|
37
39
|
- !ruby/object:Gem::Dependency
|
@@ -134,12 +136,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
137
|
none: false
|
136
138
|
requirements:
|
137
|
-
- - "
|
139
|
+
- - ">"
|
138
140
|
- !ruby/object:Gem::Version
|
139
|
-
hash:
|
141
|
+
hash: 25
|
140
142
|
segments:
|
141
|
-
-
|
142
|
-
|
143
|
+
- 1
|
144
|
+
- 3
|
145
|
+
- 1
|
146
|
+
version: 1.3.1
|
143
147
|
requirements: []
|
144
148
|
|
145
149
|
rubyforge_project: activemodel
|