Dex 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Dex.rb +12 -2
- data/lib/Dex/version.rb +1 -1
- data/spec/Dex.rb +11 -1
- metadata +1 -1
data/lib/Dex.rb
CHANGED
@@ -103,9 +103,19 @@ class Dex
|
|
103
103
|
:backtrace => e.backtrace.join("\n"),
|
104
104
|
:status => 0,
|
105
105
|
:created_at => Time.now.utc
|
106
|
-
]
|
106
|
+
]
|
107
107
|
|
108
|
-
|
108
|
+
safe_other = other.inject({}) { |m, (k,v)|
|
109
|
+
case v
|
110
|
+
when Array, Hash
|
111
|
+
m[k] = v.inspect
|
112
|
+
else
|
113
|
+
m[k] = v
|
114
|
+
end
|
115
|
+
m
|
116
|
+
}
|
117
|
+
|
118
|
+
table.insert h.merge(safe_other)
|
109
119
|
end
|
110
120
|
|
111
121
|
def remove_field name
|
data/lib/Dex/version.rb
CHANGED
data/spec/Dex.rb
CHANGED
@@ -101,7 +101,7 @@ describe "Dex :insert" do
|
|
101
101
|
}
|
102
102
|
end
|
103
103
|
|
104
|
-
it "
|
104
|
+
it "merges optional Hash with exception" do
|
105
105
|
dex = new_dex "new_fields"
|
106
106
|
dex.db.transaction(:rollback=>:always) {
|
107
107
|
id = dex.insert( except("Optional Hash"), :fd1=>"field 1", :fd2=>"field 2" )
|
@@ -109,6 +109,16 @@ describe "Dex :insert" do
|
|
109
109
|
}
|
110
110
|
end
|
111
111
|
|
112
|
+
it "applies :inspect to any Array or Hash values." do
|
113
|
+
dex = new_dex "new_fields"
|
114
|
+
dex.db.transaction(:rollback=>:always) {
|
115
|
+
id = dex.insert( except("Optional Hash"), :fd1=>[], :fd2=>{} )
|
116
|
+
r = dex.filter(:id=>id).first
|
117
|
+
r[:fd1].should == [].inspect
|
118
|
+
r[:fd2].should == {}.inspect
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
112
122
|
end # === Dex :insert
|
113
123
|
|
114
124
|
describe "Dex :keep_only" do
|