has_constant 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/has_constant.gemspec +1 -1
- data/lib/has_constant.rb +2 -2
- data/test/has_constant_test.rb +0 -5
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/has_constant.gemspec
CHANGED
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
|
-
define_method(name.to_s,
|
39
|
-
define_method(name.to_s, lambda { values
|
38
|
+
define_method(name.to_s, values) if values.respond_to?(:call)
|
39
|
+
define_method(name.to_s, lambda { values }) unless values.respond_to?(:call)
|
40
40
|
end
|
41
41
|
|
42
42
|
define_method(singular) do
|
data/test/has_constant_test.rb
CHANGED
@@ -32,11 +32,6 @@ class TestHasConstant < Test::Unit::TestCase
|
|
32
32
|
assert_equal ['Mr', 'Mrs'], Model.titles
|
33
33
|
end
|
34
34
|
|
35
|
-
should 'only use uniq values' do
|
36
|
-
Model.has_constant :titles, ['Mr', 'Mrs', 'Mr', 'Mr']
|
37
|
-
assert_equal ['Mr', 'Mrs'], Model.titles
|
38
|
-
end
|
39
|
-
|
40
35
|
should 'be able to use a proc' do
|
41
36
|
Model.has_constant :titles, Proc.new { ['Mr', 'Mrs'] }
|
42
37
|
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: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- mattbeedle
|