Dex 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/Dex.rb +12 -2
  2. data/lib/Dex/version.rb +1 -1
  3. data/spec/Dex.rb +11 -1
  4. 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
- ].merge other
106
+ ]
107
107
 
108
- table.insert h
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
@@ -1,3 +1,3 @@
1
1
  class Dex
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -101,7 +101,7 @@ describe "Dex :insert" do
101
101
  }
102
102
  end
103
103
 
104
- it "saves merges optional Hash with exception" do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Dex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: