Permalink
Browse files

adds reload method

  • Loading branch information...
1 parent 520148d commit 2e6c3b3cb7999bfec93f7f472623d713bdc8c82e @langalex committed Oct 9, 2012
Showing with 60 additions and 37 deletions.
  1. +4 −0 CHANGES.md
  2. +4 −4 Gemfile.lock
  3. +11 −11 active_support_3_0.lock
  4. +11 −11 active_support_3_1.lock
  5. +10 −10 active_support_3_2.lock
  6. +1 −1 couch_potato.gemspec
  7. +5 −0 lib/couch_potato/persistence.rb
  8. +14 −0 spec/reload_spec.rb
View
@@ -1,5 +1,9 @@
## Changes
+### Current
+
+* adds `reload` method (Alexander Lang)
+
### 0.7.1
* fixes a bug when trying to bulk-load non-existant documents
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- couch_potato (0.7.0)
+ couch_potato (0.7.1)
activemodel
couchrest (>= 1.0.1)
json (~> 1.6)
@@ -21,7 +21,7 @@ GEM
multi_json (~> 1.0)
rest-client (~> 1.6.1)
diff-lcs (1.1.3)
- i18n (0.6.0)
+ i18n (0.6.1)
json (1.7.5)
libv8 (3.3.10.4)
mime-types (1.19)
@@ -34,9 +34,9 @@ GEM
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
- rspec-expectations (2.11.2)
+ rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.11.2)
+ rspec-mocks (2.11.3)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
timecop (0.4.5)
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- couch_potato (0.7.0)
+ couch_potato (0.7.1)
activemodel
couchrest (>= 1.0.1)
json (~> 1.6)
@@ -19,7 +19,7 @@ GEM
mime-types (~> 1.15)
multi_json (~> 1.0)
rest-client (~> 1.6.1)
- diff-lcs (1.1.2)
+ diff-lcs (1.1.3)
i18n (0.5.0)
json (1.7.5)
libv8 (3.3.10.4)
@@ -28,14 +28,14 @@ GEM
rake (0.8.7)
rest-client (1.6.7)
mime-types (>= 1.16)
- rspec (2.5.0)
- rspec-core (~> 2.5.0)
- rspec-expectations (~> 2.5.0)
- rspec-mocks (~> 2.5.0)
- rspec-core (2.5.1)
- rspec-expectations (2.5.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.5.0)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.3)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
timecop (0.3.5)
@@ -48,7 +48,7 @@ DEPENDENCIES
activemodel (~> 3.0)
couch_potato!
rake
- rspec (>= 2.0)
+ rspec (~> 2.11.0)
therubyracer
timecop
tzinfo
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- couch_potato (0.7.0)
+ couch_potato (0.7.1)
activemodel
couchrest (>= 1.0.1)
json (~> 1.6)
@@ -22,7 +22,7 @@ GEM
mime-types (~> 1.15)
multi_json (~> 1.0)
rest-client (~> 1.6.1)
- diff-lcs (1.1.2)
+ diff-lcs (1.1.3)
i18n (0.6.0)
json (1.7.5)
libv8 (3.3.10.4)
@@ -31,14 +31,14 @@ GEM
rake (0.9.2)
rest-client (1.6.7)
mime-types (>= 1.16)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.3)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
timecop (0.3.5)
@@ -51,7 +51,7 @@ DEPENDENCIES
activemodel (~> 3.1.0)
couch_potato!
rake
- rspec (>= 2.0)
+ rspec (~> 2.11.0)
therubyracer
timecop
tzinfo
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- couch_potato (0.7.0)
+ couch_potato (0.7.1)
activemodel
couchrest (>= 1.0.1)
json (~> 1.6)
@@ -29,14 +29,14 @@ GEM
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.3)
therubyracer (0.10.1)
libv8 (~> 3.3.10)
timecop (0.3.5)
@@ -49,7 +49,7 @@ DEPENDENCIES
activemodel (~> 3.2)
couch_potato!
rake
- rspec (>= 2.0)
+ rspec (~> 2.11.0)
therubyracer
timecop
tzinfo
View
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.add_dependency 'couchrest', '>=1.0.1'
s.add_dependency 'activemodel'
- s.add_development_dependency 'rspec', '>=2.0'
+ s.add_development_dependency 'rspec', '~>2.11.0'
s.add_development_dependency 'timecop'
s.add_development_dependency 'tzinfo'
s.add_development_dependency 'rake'
@@ -132,6 +132,11 @@ def hash
_id.hash * (_id.hash.to_s.size ** 10) + _rev.hash
end
+ # Returns a reloaded instance. Does not touch the original instance.
+ def reload
+ database.load id
+ end
+
def inspect
attributes_as_string = attributes.map {|attribute, value| "#{attribute}: #{value.inspect}"}.join(", ")
%Q{#<#{self.class} _id: "#{_id}", _rev: "#{_rev}", #{attributes_as_string}>}
View
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe CouchPotato::Persistence, '#reload' do
+ let(:db) { CouchPotato.database }
+
+ it 'returns a new instance from the database' do
+ comment = Comment.new title: 'hello'
+ db.save! comment
+
+ reloaded = comment.reload
+ expect(reloaded.object_id).to_not eql(comment.object_id)
+ expect(reloaded).to eql(comment)
+ end
+end

0 comments on commit 2e6c3b3

Please sign in to comment.