has_constant 0.4.0 → 0.4.1
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.
- data/VERSION +1 -1
- data/has_constant.gemspec +2 -2
- data/lib/has_constant.rb +2 -2
- data/test/has_constant_test.rb +5 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
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.4.
|
8
|
+
s.version = "0.4.1"
|
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-01-
|
12
|
+
s.date = %q{2011-01-17}
|
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 = [
|
data/lib/has_constant.rb
CHANGED
@@ -35,8 +35,8 @@ module HasConstant
|
|
35
35
|
singular = (options[:accessor] || name.to_s.singularize).to_s
|
36
36
|
|
37
37
|
(class << self; self; end).instance_eval do
|
38
|
-
|
39
|
-
define_method(name.to_s, lambda { values })
|
38
|
+
values = values.call if values.respond_to?(:call)
|
39
|
+
define_method(name.to_s, lambda { values.uniq })
|
40
40
|
end
|
41
41
|
|
42
42
|
define_method(singular) do
|
data/test/has_constant_test.rb
CHANGED
@@ -32,6 +32,11 @@ class TestHasConstant < Test::Unit::TestCase
|
|
32
32
|
assert_equal ['Mr', 'Mrs'], Model.titles
|
33
33
|
end
|
34
34
|
|
35
|
+
should 'only take uniq values' do
|
36
|
+
Model.has_constant :titles, ['Mr', 'Mr', 'Mrs', 'Mr']
|
37
|
+
assert_equal ['Mr', 'Mrs'], Model.titles
|
38
|
+
end
|
39
|
+
|
35
40
|
should 'be able to use a proc' do
|
36
41
|
Model.has_constant :titles, Proc.new { ['Mr', 'Mrs'] }
|
37
42
|
assert_equal ['Mr', 'Mrs'], Model.titles
|
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:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
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-01-
|
18
|
+
date: 2011-01-17 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|