ocean-rails 1.29.8 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ocean/ocean_application_controller.rb +8 -2
- data/lib/ocean/ocean_resource_model.rb +13 -3
- data/lib/ocean/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863039deb04d7de0a448aabad3e79e9d46750b6f
|
4
|
+
data.tar.gz: 852f15e75dc0a64597fc5efec6f2afecae849d4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1a728efdbf916de100afe944768a2f149ec5a6cdb767a3523eb5c9350ae418483e2e43b4660b64746a5f536fefadc156e00ec1041d8394a551875b86596069
|
7
|
+
data.tar.gz: f918875849a5b4bf410a639d6620590afdbd75d9f0a7d40ff7555629916a194c42e12e25f7df823d242b691a262d2b0b7c1a1fbdf52525c5d462b71e19c230e8
|
@@ -206,8 +206,14 @@ module OceanApplicationController
|
|
206
206
|
# member.
|
207
207
|
#
|
208
208
|
def collection_etag(coll)
|
209
|
-
coll.name.constantize # Force a load of the class (for secondary collections)
|
210
|
-
|
209
|
+
klass = coll.name.constantize # Force a load of the class (for secondary collections)
|
210
|
+
timestamp = klass.update_timestamp || klass.create_timestamp
|
211
|
+
if (timestamp)
|
212
|
+
last_item = coll.reorder(timestamp).last
|
213
|
+
last_updated = last_item ? last_item.send(timestamp).utc : 0
|
214
|
+
else
|
215
|
+
last_updated = 0
|
216
|
+
end
|
211
217
|
# We could also, in the absence of an updated_at attribute, use created_at.
|
212
218
|
{ etag: "#{coll.name}:#{coll.count}:#{last_updated}"
|
213
219
|
}
|
@@ -38,12 +38,18 @@ module Ocean
|
|
38
38
|
# enumerating the Varnish +BAN+ HTTP request URI suffixes to use to invalidate a
|
39
39
|
# collection of resources.
|
40
40
|
#
|
41
|
+
# +create_timestamp+ and +update_timestamp+ default to +:created_at+ and +:updated_at+,
|
42
|
+
# respectively, naming the attribute containing the timestamps for resource creation
|
43
|
+
# and modification. Either one may be nil or false.
|
44
|
+
#
|
41
45
|
def ocean_resource_model(index: [:name],
|
42
46
|
ranged: [],
|
43
47
|
search: :description,
|
44
48
|
page_size: 25,
|
45
49
|
invalidate_member: INVALIDATE_MEMBER_DEFAULT,
|
46
|
-
invalidate_collection: INVALIDATE_COLLECTION_DEFAULT
|
50
|
+
invalidate_collection: INVALIDATE_COLLECTION_DEFAULT,
|
51
|
+
create_timestamp: :created_at,
|
52
|
+
update_timestamp: :updated_at
|
47
53
|
)
|
48
54
|
include ApiResource
|
49
55
|
cattr_accessor :index_only
|
@@ -52,12 +58,16 @@ module Ocean
|
|
52
58
|
cattr_accessor :collection_page_size
|
53
59
|
cattr_accessor :varnish_invalidate_member
|
54
60
|
cattr_accessor :varnish_invalidate_collection
|
55
|
-
|
61
|
+
cattr_accessor :create_timestamp
|
62
|
+
cattr_accessor :update_timestamp
|
63
|
+
self.index_only = index
|
56
64
|
self.ranged_matchers = ranged
|
57
|
-
|
65
|
+
self.index_search_property = search
|
58
66
|
self.collection_page_size = page_size
|
59
67
|
self.varnish_invalidate_member = invalidate_member
|
60
68
|
self.varnish_invalidate_collection = invalidate_collection
|
69
|
+
self.create_timestamp = create_timestamp
|
70
|
+
self.update_timestamp = update_timestamp
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
data/lib/ocean/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocean-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bengtson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|