unidata 0.0.6 → 0.0.7
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/unidata/extensions/date.rb +1 -1
- data/lib/unidata/field.rb +2 -0
- data/lib/unidata/model.rb +11 -1
- data/lib/unidata/version.rb +1 -1
- data/spec/unidata/field_spec.rb +6 -1
- metadata +2 -2
data/lib/unidata/field.rb
CHANGED
data/lib/unidata/model.rb
CHANGED
@@ -34,7 +34,17 @@ module Unidata
|
|
34
34
|
|
35
35
|
value = instance.send(key)
|
36
36
|
next if value.nil?
|
37
|
-
|
37
|
+
|
38
|
+
a_field, a_value, a_subvalue = field.index
|
39
|
+
a_string = field.to_unidata(value)
|
40
|
+
|
41
|
+
if a_subvalue
|
42
|
+
record.replace a_field, a_value, a_subvalue, a_string
|
43
|
+
elsif a_value
|
44
|
+
record.replace a_field, a_value, a_string
|
45
|
+
else
|
46
|
+
record.replace a_field, a_string
|
47
|
+
end
|
38
48
|
end
|
39
49
|
|
40
50
|
record
|
data/lib/unidata/version.rb
CHANGED
data/spec/unidata/field_spec.rb
CHANGED
@@ -11,9 +11,14 @@ describe Unidata::Field do
|
|
11
11
|
field.type.should == Date
|
12
12
|
end
|
13
13
|
|
14
|
-
it 'accepts multivalued indexes' do
|
14
|
+
it 'accepts multivalued indexes with 1-3 levels' do
|
15
15
|
field = subject.new([1,2], :name)
|
16
16
|
field.index.should == [1,2]
|
17
|
+
|
18
|
+
field = subject.new([1,2,3], :age)
|
19
|
+
field.index.should == [1,2,3]
|
20
|
+
|
21
|
+
expect { subject.new([1,2,3,4], :invalid) }.to raise_error(ArgumentError, 'index must be 1-3 levels')
|
17
22
|
end
|
18
23
|
|
19
24
|
it 'defaults type to String' do
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: unidata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jeremy Israelsen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|