superstore 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/superstore.rb +1 -0
- data/lib/superstore/adapters/hstore_adapter.rb +6 -3
- data/lib/superstore/base.rb +1 -0
- data/lib/superstore/caching.rb +13 -0
- data/lib/superstore/core.rb +1 -1
- data/lib/superstore/scope.rb +2 -1
- data/lib/superstore/scope/batches.rb +1 -1
- data/lib/superstore/scope/query_methods.rb +9 -0
- data/superstore.gemspec +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/caching_test.rb +20 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84669dc1d087ef650432331ba37250ac34d475da
|
4
|
+
data.tar.gz: 4b9cbfdf901f62b442001cf2d255056b836fc6d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0486ef130ad6e9b9687a95ff025232247768d07e218c653ea37a159b3cbfab3a8a4994cc88f6541ed573aaedb9a8119ad49106ae0462726c28af69cbdbfd7f9d
|
7
|
+
data.tar.gz: 400d2752bff7dc31c12dbfbbca412563b79e8853e7f305d4230856c57e15e2a00b366a38f6658029779f82c03f7b58746e7cee887a58b9b3f621aa6ebcb0258e
|
data/lib/superstore.rb
CHANGED
@@ -15,7 +15,7 @@ module Superstore
|
|
15
15
|
"SELECT #{select_string} FROM #{@scope.klass.column_family}",
|
16
16
|
where_string,
|
17
17
|
order_string,
|
18
|
-
limit_string
|
18
|
+
limit_string
|
19
19
|
].delete_if(&:blank?) * ' '
|
20
20
|
end
|
21
21
|
|
@@ -39,7 +39,10 @@ module Superstore
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def order_string
|
42
|
-
if @scope.
|
42
|
+
if @scope.order_values.any?
|
43
|
+
orders = @scope.order_values.join(', ')
|
44
|
+
"ORDER BY #{orders}"
|
45
|
+
elsif @scope.id_values.many?
|
43
46
|
id_orders = @scope.id_values.map { |id| "ID=#{@adapter.quote(id)} DESC" }.join(',')
|
44
47
|
"ORDER BY #{id_orders}"
|
45
48
|
end
|
@@ -160,4 +163,4 @@ module Superstore
|
|
160
163
|
end
|
161
164
|
end
|
162
165
|
end
|
163
|
-
end
|
166
|
+
end
|
data/lib/superstore/base.rb
CHANGED
data/lib/superstore/core.rb
CHANGED
data/lib/superstore/scope.rb
CHANGED
@@ -7,7 +7,7 @@ module Superstore
|
|
7
7
|
include Batches, FinderMethods, QueryMethods
|
8
8
|
|
9
9
|
attr_accessor :klass
|
10
|
-
attr_accessor :limit_value, :select_values, :where_values, :id_values
|
10
|
+
attr_accessor :limit_value, :select_values, :where_values, :id_values, :order_values
|
11
11
|
|
12
12
|
def initialize(klass)
|
13
13
|
@klass = klass
|
@@ -15,6 +15,7 @@ module Superstore
|
|
15
15
|
@limit_value = nil
|
16
16
|
@select_values = []
|
17
17
|
@where_values = []
|
18
|
+
@order_values = []
|
18
19
|
@id_values = []
|
19
20
|
end
|
20
21
|
|
data/superstore.gemspec
CHANGED
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Superstore::CachingTest < Superstore::TestCase
|
4
|
+
class ::OtherClass < Superstore::Base
|
5
|
+
end
|
6
|
+
|
7
|
+
test 'for a new record' do
|
8
|
+
issue = Issue.new
|
9
|
+
other_class = OtherClass.new
|
10
|
+
assert_equal "issues/new", issue.cache_key
|
11
|
+
assert_equal "other_classes/new", other_class.cache_key
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'for a persisted record' do
|
15
|
+
updated_at = Time.now
|
16
|
+
issue = Issue.create!(id: 1, updated_at: updated_at)
|
17
|
+
|
18
|
+
assert_equal "issues/1-#{updated_at}", issue.cache_key
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Koziarski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- lib/superstore/belongs_to/association.rb
|
69
69
|
- lib/superstore/belongs_to/builder.rb
|
70
70
|
- lib/superstore/belongs_to/reflection.rb
|
71
|
+
- lib/superstore/caching.rb
|
71
72
|
- lib/superstore/callbacks.rb
|
72
73
|
- lib/superstore/cassandra_schema.rb
|
73
74
|
- lib/superstore/cassandra_schema/statements.rb
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- test/unit/base_test.rb
|
120
121
|
- test/unit/belongs_to/reflection_test.rb
|
121
122
|
- test/unit/belongs_to_test.rb
|
123
|
+
- test/unit/caching_test.rb
|
122
124
|
- test/unit/callbacks_test.rb
|
123
125
|
- test/unit/cassandra_schema/statements_test.rb
|
124
126
|
- test/unit/cassandra_schema/tasks_test.rb
|
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
167
|
version: 1.3.5
|
166
168
|
requirements: []
|
167
169
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.2.
|
170
|
+
rubygems_version: 2.2.2
|
169
171
|
signing_key:
|
170
172
|
specification_version: 4
|
171
173
|
summary: Cassandra ActiveModel
|