activemodel 3.0.4 → 3.0.5.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,9 +8,26 @@ module ActiveModel
8
8
  ":in option of the configuration hash" unless options[:in].respond_to?(:include?)
9
9
  end
10
10
 
11
- def validate_each(record, attribute, value)
12
- unless options[:in].include?(value)
13
- record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value))
11
+ # On Ruby 1.9 Range#include? checks all possible values in the range for equality,
12
+ # so it may be slow for large ranges. The new Range#cover? uses the previous logic
13
+ # of comparing a value with the range endpoints.
14
+ if (1..2).respond_to?(:cover?)
15
+ def validate_each(record, attribute, value)
16
+ included = if options[:in].is_a?(Range)
17
+ options[:in].cover?(value)
18
+ else
19
+ options[:in].include?(value)
20
+ end
21
+
22
+ unless included
23
+ record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value))
24
+ end
25
+ end
26
+ else
27
+ def validate_each(record, attribute, value)
28
+ unless options[:in].include?(value)
29
+ record.errors.add(attribute, :inclusion, options.except(:in).merge!(:value => value))
30
+ end
14
31
  end
15
32
  end
16
33
  end
@@ -2,8 +2,8 @@ module ActiveModel
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 4
6
- PRE = nil
5
+ TINY = 5
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
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: 15
5
- prerelease: false
4
+ hash: 15424095
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 4
10
- version: 3.0.4
9
+ - 5
10
+ - rc
11
+ - 1
12
+ version: 3.0.5.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Heinemeier Hansson
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-02-09 00:00:00 +13:00
20
+ date: 2011-02-22 00:00:00 -08:00
19
21
  default_executable:
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
@@ -26,12 +28,14 @@ dependencies:
26
28
  requirements:
27
29
  - - "="
28
30
  - !ruby/object:Gem::Version
29
- hash: 15
31
+ hash: 15424095
30
32
  segments:
31
33
  - 3
32
34
  - 0
33
- - 4
34
- version: 3.0.4
35
+ - 5
36
+ - rc
37
+ - 1
38
+ version: 3.0.5.rc1
35
39
  type: :runtime
36
40
  version_requirements: *id001
37
41
  - !ruby/object:Gem::Dependency
@@ -134,16 +138,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
138
  required_rubygems_version: !ruby/object:Gem::Requirement
135
139
  none: false
136
140
  requirements:
137
- - - ">="
141
+ - - ">"
138
142
  - !ruby/object:Gem::Version
139
- hash: 3
143
+ hash: 25
140
144
  segments:
141
- - 0
142
- version: "0"
145
+ - 1
146
+ - 3
147
+ - 1
148
+ version: 1.3.1
143
149
  requirements: []
144
150
 
145
151
  rubyforge_project: activemodel
146
- rubygems_version: 1.3.7
152
+ rubygems_version: 1.5.2
147
153
  signing_key:
148
154
  specification_version: 3
149
155
  summary: A toolkit for building modeling frameworks (part of Rails).