loose_change 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/loose_change/attachments.rb +1 -1
- data/lib/loose_change/base.rb +0 -1
- data/lib/loose_change/persistence.rb +6 -3
- data/loose_change.gemspec +1 -1
- data/test/persistence_test.rb +9 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -54,7 +54,7 @@ module LooseChange
|
|
54
54
|
result = JSON.parse(RestClient.put("#{ uri }/#{ name }#{ '?rev=' + @_rev if @_rev }", attachments[name][:file], {:content_type => attachments[name][:content_type], :accept => 'text/json'}))
|
55
55
|
@_rev = result['rev']
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
data/lib/loose_change/base.rb
CHANGED
@@ -42,9 +42,8 @@ module LooseChange
|
|
42
42
|
# Build a Loose Change record from a hash of attributes +hash+ as
|
43
43
|
# returned by CouchDB.
|
44
44
|
def instantiate_from_hash(hash)
|
45
|
-
model = new(hash.reject {|k, _| 'model_name' == k
|
45
|
+
model = new(hash.reject {|k, _| 'model_name' == k})
|
46
46
|
model.id = hash['_id']
|
47
|
-
model._attachments = hash['_attachments']
|
48
47
|
model.new_record = false
|
49
48
|
if hash['_attachments']
|
50
49
|
attachment_names = hash['_attachments'].map {|name, _| name}
|
@@ -124,7 +123,11 @@ module LooseChange
|
|
124
123
|
end
|
125
124
|
|
126
125
|
def put_record
|
127
|
-
|
126
|
+
if self._attachments
|
127
|
+
result = JSON.parse(RestClient.put(uri, self.to_json(:methods => [:model_name, :_rev, :_id, :_attachments], :except => [:id]), default_headers))
|
128
|
+
else
|
129
|
+
result = JSON.parse(RestClient.put(uri, self.to_json(:methods => [:model_name, :_rev, :_id], :except => [:id]), default_headers))
|
130
|
+
end
|
128
131
|
@_rev = result['rev']
|
129
132
|
result
|
130
133
|
end
|
data/loose_change.gemspec
CHANGED
data/test/persistence_test.rb
CHANGED
@@ -122,5 +122,14 @@ class PersistenceTest < ActiveSupport::TestCase
|
|
122
122
|
assert_times_close time, new_model.created_at
|
123
123
|
Timecop.return
|
124
124
|
end
|
125
|
+
|
126
|
+
should "handle multiple saves and changes" do
|
127
|
+
@model.save
|
128
|
+
@model = TestModel.find(@model.id)
|
129
|
+
@model.age = "S,M,L,XL,2X".split ','
|
130
|
+
@model.name = 10
|
131
|
+
@model.save
|
132
|
+
end
|
133
|
+
|
125
134
|
|
126
135
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joshua Miller
|
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
hash:
|
134
|
+
hash: 1769435733236060489
|
135
135
|
segments:
|
136
136
|
- 0
|
137
137
|
version: "0"
|