ns-options 1.0.0.rc2 → 1.0.0.rc3
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/lib/ns-options/option.rb +6 -4
- data/lib/ns-options/version.rb +1 -1
- data/test/unit/option_tests.rb +11 -3
- metadata +4 -4
data/lib/ns-options/option.rb
CHANGED
@@ -90,13 +90,15 @@ module NsOptions
|
|
90
90
|
return value if no_coercing_needed?(value)
|
91
91
|
|
92
92
|
begin
|
93
|
-
if [ Integer, Float, String ].include?(self.type_class)
|
93
|
+
if [ ::Integer, ::Float, ::String ].include?(self.type_class)
|
94
94
|
# ruby type conversion, i.e. String(1)
|
95
95
|
Object.send(self.type_class.to_s, value)
|
96
|
-
elsif self.type_class == Symbol
|
96
|
+
elsif self.type_class == ::Symbol
|
97
97
|
value.to_sym
|
98
|
-
elsif self.type_class ==
|
99
|
-
|
98
|
+
elsif self.type_class == ::Array
|
99
|
+
::Array.new([*value])
|
100
|
+
elsif self.type_class == ::Hash
|
101
|
+
::Hash.new.merge(value)
|
100
102
|
else
|
101
103
|
self.type_class.new(value, *self.rules[:args])
|
102
104
|
end
|
data/lib/ns-options/version.rb
CHANGED
data/test/unit/option_tests.rb
CHANGED
@@ -269,9 +269,17 @@ class NsOptions::Option
|
|
269
269
|
subject{ @option }
|
270
270
|
|
271
271
|
should "allow setting it with a array" do
|
272
|
-
|
273
|
-
subject.value =
|
274
|
-
|
272
|
+
expected = [ :something, :else, :another ]
|
273
|
+
subject.value = [ :something, :else, :another ]
|
274
|
+
|
275
|
+
assert_equal expected, subject.value
|
276
|
+
end
|
277
|
+
|
278
|
+
should "allow setting it with a single value" do
|
279
|
+
expected = [ :something ]
|
280
|
+
subject.value = :something
|
281
|
+
|
282
|
+
assert_equal expected, subject.value
|
275
283
|
end
|
276
284
|
|
277
285
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ns-options
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1486472869
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 1.0.0.
|
11
|
+
- 3
|
12
|
+
version: 1.0.0.rc3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Collin Redding
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2012-11-
|
21
|
+
date: 2012-11-29 00:00:00 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: assert
|