simple_enum 1.6.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/lib/simple_enum/mongoid.rb +1 -1
- data/lib/simple_enum/version.rb +1 -1
- data/test/mongoid_test.rb +12 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/lib/simple_enum/mongoid.rb
CHANGED
@@ -36,7 +36,7 @@ module SimpleEnum
|
|
36
36
|
# Wrap method chain to create mongoid field and additional
|
37
37
|
# column options
|
38
38
|
def as_enum_with_mongoid(enum_cd, values, options = {})
|
39
|
-
options = SimpleEnum.default_options.merge({ :column => "#{enum_cd}_cd" }).
|
39
|
+
options = SimpleEnum.default_options.merge({ :column => "#{enum_cd}_cd" }).deep_merge(options)
|
40
40
|
|
41
41
|
# forward custom field options
|
42
42
|
field_options = options.delete(:field)
|
data/lib/simple_enum/version.rb
CHANGED
data/test/mongoid_test.rb
CHANGED
@@ -51,4 +51,16 @@ class MongoidTest < MiniTest::Unit::TestCase
|
|
51
51
|
refute_nil klass.new.fields['gender_cd']
|
52
52
|
assert_equal String, klass.new.fields['gender_cd'].options[:type]
|
53
53
|
end
|
54
|
+
|
55
|
+
def test_default_field_options_are_merged_recursivly
|
56
|
+
skip('Only available in mongoid') unless mongoid?
|
57
|
+
SimpleEnum.default_options[:field] = { :type => String }
|
58
|
+
klass = anonymous_dummy do
|
59
|
+
as_enum :gender, [:male, :female], :field => { :default => "0" }
|
60
|
+
end
|
61
|
+
|
62
|
+
refute_nil klass.new.fields['gender_cd']
|
63
|
+
assert_equal String, klass.new.fields['gender_cd'].options[:type]
|
64
|
+
assert_equal "0", klass.new.fields['gender_cd'].options[:default]
|
65
|
+
end
|
54
66
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 1.6.
|
9
|
+
- 4
|
10
|
+
version: 1.6.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lukas Westermann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-10-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|