has_constant 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.8.0
data/has_constant.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_constant}
8
- s.version = "0.7.3"
8
+ s.version = "0.8.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mattbeedle"]
12
- s.date = %q{2011-03-23}
12
+ s.date = %q{2011-03-28}
13
13
  s.description = %q{Allows certain fields to be limited to a set of values}
14
14
  s.email = %q{mattbeedle@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -101,7 +101,14 @@ module HasConstant
101
101
  else
102
102
  define_method "#{singular}_is".to_sym do |values|
103
103
  values = values.lines.to_a if values.respond_to?(:lines)
104
- where(singular.to_sym.in => values.map { |v| self.send(name.to_sym).index(v) })
104
+ where(singular.to_sym.in => values.map do |v|
105
+ options = self.send(name.to_sym)
106
+ if options.respond_to?(:key)
107
+ options.key(v)
108
+ else
109
+ options.index(v)
110
+ end
111
+ end)
105
112
  end
106
113
 
107
114
  define_method "#{singular}_is_not".to_sym do |values|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_constant
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 3
10
- version: 0.7.3
8
+ - 8
9
+ - 0
10
+ version: 0.8.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - mattbeedle
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-23 00:00:00 +01:00
18
+ date: 2011-03-28 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency