has_constant 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1,3 +1,3 @@
1
1
  rvm_gemset_create_on_use_flag=1
2
- rvm use 1.8.7
2
+ rvm use 1.9.3
3
3
  rvm gemset use has_constant
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.3
1
+ 0.8.4
data/has_constant.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{has_constant}
8
- s.version = "0.8.3"
7
+ s.name = "has_constant"
8
+ s.version = "0.8.4"
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-08-24}
13
- s.description = %q{Allows certain fields to be limited to a set of values}
14
- s.email = %q{mattbeedle@gmail.com}
12
+ s.date = "2011-11-09"
13
+ s.description = "Allows certain fields to be limited to a set of values"
14
+ s.email = "mattbeedle@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.rdoc"
@@ -34,10 +34,10 @@ Gem::Specification.new do |s|
34
34
  "test/unit/orm/active_model_test.rb",
35
35
  "test/unit/orm/mongoid_test.rb"
36
36
  ]
37
- s.homepage = %q{http://github.com/mattbeedle/has_constant}
37
+ s.homepage = "http://github.com/mattbeedle/has_constant"
38
38
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.5.2}
40
- s.summary = %q{Allows certain fields to be limited to a set of values}
39
+ s.rubygems_version = "1.8.10"
40
+ s.summary = "Allows certain fields to be limited to a set of values"
41
41
  s.test_files = [
42
42
  "test/has_constant_test.rb",
43
43
  "test/helper.rb",
@@ -40,20 +40,22 @@ module HasConstant
40
40
 
41
41
  index singular.to_sym, :background => true if options[:index]
42
42
 
43
- named_scope :by_constant, lambda { |constant, value|
44
- if self.send(constant.pluralize).respond_to?(:key)
45
- value_for_query = self.send(constant.pluralize).key(value)
46
- value_for_query ||= I18n.with_locale(:en) do
47
- self.send(constant.pluralize).key(value)
48
- end
49
- else
50
- value_for_query = self.send(constant.pluralize).index(value)
51
- value_for_query ||= I18n.with_locale(:en) do
52
- send(contant.pluralize).index(value)
43
+ unless respond_to?(:by_constant)
44
+ named_scope :by_constant, lambda { |constant, value|
45
+ if self.send(constant.pluralize).respond_to?(:key)
46
+ value_for_query = self.send(constant.pluralize).key(value)
47
+ value_for_query ||= I18n.with_locale(:en) do
48
+ self.send(constant.pluralize).key(value)
49
+ end
50
+ else
51
+ value_for_query = self.send(constant.pluralize).index(value)
52
+ value_for_query ||= I18n.with_locale(:en) do
53
+ send(contant.pluralize).index(value)
54
+ end
53
55
  end
54
- end
55
- where(constant.to_sym => value_for_query)
56
- }
56
+ where(constant.to_sym => value_for_query)
57
+ }
58
+ end
57
59
  end
58
60
 
59
61
  # Define the setter method here
metadata CHANGED
@@ -1,75 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: has_constant
3
- version: !ruby/object:Gem::Version
4
- hash: 57
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.4
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 3
10
- version: 0.8.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - mattbeedle
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-24 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :development
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
12
+ date: 2011-11-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
32
15
  name: jeweler
33
- version_requirements: *id001
34
- prerelease: false
35
- - !ruby/object:Gem::Dependency
36
- type: :development
37
- requirement: &id002 !ruby/object:Gem::Requirement
16
+ requirement: &70313217138540 !ruby/object:Gem::Requirement
38
17
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
46
- name: shoulda
47
- version_requirements: *id002
48
- prerelease: false
49
- - !ruby/object:Gem::Dependency
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
50
22
  type: :development
51
- requirement: &id003 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *70313217138540
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &70313217138020 !ruby/object:Gem::Requirement
52
28
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70313217138020
36
+ - !ruby/object:Gem::Dependency
60
37
  name: activesupport
61
- version_requirements: *id003
38
+ requirement: &70313217137540 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
62
45
  prerelease: false
46
+ version_requirements: *70313217137540
63
47
  description: Allows certain fields to be limited to a set of values
64
48
  email: mattbeedle@gmail.com
65
49
  executables: []
66
-
67
50
  extensions: []
68
-
69
- extra_rdoc_files:
51
+ extra_rdoc_files:
70
52
  - LICENSE
71
53
  - README.rdoc
72
- files:
54
+ files:
73
55
  - .document
74
56
  - .rvmrc
75
57
  - Gemfile
@@ -86,41 +68,31 @@ files:
86
68
  - test/helper.rb
87
69
  - test/unit/orm/active_model_test.rb
88
70
  - test/unit/orm/mongoid_test.rb
89
- has_rdoc: true
90
71
  homepage: http://github.com/mattbeedle/has_constant
91
72
  licenses: []
92
-
93
73
  post_install_message:
94
74
  rdoc_options: []
95
-
96
- require_paths:
75
+ require_paths:
97
76
  - lib
98
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
99
78
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
107
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
84
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
116
89
  requirements: []
117
-
118
90
  rubyforge_project:
119
- rubygems_version: 1.5.2
91
+ rubygems_version: 1.8.10
120
92
  signing_key:
121
93
  specification_version: 3
122
94
  summary: Allows certain fields to be limited to a set of values
123
- test_files:
95
+ test_files:
124
96
  - test/has_constant_test.rb
125
97
  - test/helper.rb
126
98
  - test/unit/orm/active_model_test.rb