simply_stored 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -15,13 +15,13 @@ module SimplyStored
|
|
15
15
|
if with_deleted || !soft_deleting_enabled?
|
16
16
|
CouchPotato.database.view(all_documents(*args))
|
17
17
|
else
|
18
|
-
CouchPotato.database.view(all_documents_without_deleted(options
|
18
|
+
CouchPotato.database.view(all_documents_without_deleted(options))
|
19
19
|
end
|
20
20
|
when :first
|
21
21
|
if with_deleted || !soft_deleting_enabled?
|
22
22
|
CouchPotato.database.view(all_documents(:limit => 1)).first
|
23
23
|
else
|
24
|
-
CouchPotato.database.view(all_documents_without_deleted(:
|
24
|
+
CouchPotato.database.view(all_documents_without_deleted(:limit => 1)).first
|
25
25
|
end
|
26
26
|
else
|
27
27
|
raise SimplyStored::Error, "Can't load record without an id" if what.nil?
|
@@ -52,7 +52,7 @@ module SimplyStored
|
|
52
52
|
if with_deleted || !soft_deleting_enabled?
|
53
53
|
CouchPotato.database.view(all_documents(:reduce => true))
|
54
54
|
else
|
55
|
-
CouchPotato.database.view(all_documents_without_deleted(:reduce => true
|
55
|
+
CouchPotato.database.view(all_documents_without_deleted(:reduce => true))
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SimplyStored
|
2
|
+
module Couch
|
3
|
+
module Views
|
4
|
+
class DeletedModelViewSpec < CouchPotato::View::CustomViewSpec
|
5
|
+
def map_function
|
6
|
+
<<-eos
|
7
|
+
function(doc) {
|
8
|
+
if (doc.ruby_class && doc.ruby_class == '#{@klass.name}') {
|
9
|
+
if (doc['#{@klass.soft_delete_attribute}'] && doc['#{@klass.soft_delete_attribute}'] != null){
|
10
|
+
// "soft" deleted
|
11
|
+
}else{
|
12
|
+
emit(doc.created_at, 1);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
eos
|
17
|
+
end
|
18
|
+
|
19
|
+
def reduce_function
|
20
|
+
'_sum'
|
21
|
+
end
|
22
|
+
|
23
|
+
def view_parameters
|
24
|
+
_super = super
|
25
|
+
if _super[:reduce]
|
26
|
+
_super
|
27
|
+
else
|
28
|
+
{:include_docs => true, :reduce => false}.merge(_super)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def process_results(results)
|
33
|
+
if count?
|
34
|
+
results['rows'].first.try(:[], 'value') || 0
|
35
|
+
else
|
36
|
+
results['rows'].map { |row| row['doc'] || row['id'] }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1 +1,2 @@
|
|
1
|
-
require 'simply_stored/couch/views/array_property_view_spec'
|
1
|
+
require 'simply_stored/couch/views/array_property_view_spec'
|
2
|
+
require 'simply_stored/couch/views/deleted_model_view_spec'
|
data/lib/simply_stored/couch.rb
CHANGED
@@ -134,8 +134,8 @@ module SimplyStored
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
def _define_soft_delete_views
|
138
|
-
view :all_documents_without_deleted, :
|
137
|
+
def _define_soft_delete_views
|
138
|
+
view :all_documents_without_deleted, :type => SimplyStored::Couch::Views::DeletedModelViewSpec
|
139
139
|
end
|
140
140
|
|
141
141
|
def _define_cache_accessors(name, options)
|
data/lib/simply_stored.rb
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/simply_stored/storage')
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/simply_stored/class_methods_base')
|
5
5
|
|
6
6
|
module SimplyStored
|
7
|
-
VERSION = '0.5.
|
7
|
+
VERSION = '0.5.2'
|
8
8
|
class Error < RuntimeError; end
|
9
9
|
class RecordNotFound < RuntimeError; end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simply_stored
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mathias Meyer, Jonathan Weiss
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-30 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/simply_stored/couch/validations.rb
|
108
108
|
- lib/simply_stored/couch/views.rb
|
109
109
|
- lib/simply_stored/couch/views/array_property_view_spec.rb
|
110
|
+
- lib/simply_stored/couch/views/deleted_model_view_spec.rb
|
110
111
|
- lib/simply_stored/instance_methods.rb
|
111
112
|
- lib/simply_stored/rake.rb
|
112
113
|
- lib/simply_stored/storage.rb
|