ocean-rails 1.29.8 → 1.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28a1c6e8f241193e243d74f615f22d5d5f86920d
4
- data.tar.gz: 2819b6adb6e7197052dee4d7ed5c20093fb11a18
3
+ metadata.gz: 863039deb04d7de0a448aabad3e79e9d46750b6f
4
+ data.tar.gz: 852f15e75dc0a64597fc5efec6f2afecae849d4d
5
5
  SHA512:
6
- metadata.gz: 13a439e08406f55ffd6b4d9f231cecf60d76f863375ddd4773fea9fce68157a2f973af188f8c7a820eb5fceee82f2f483888edd9ba471dc162aed031dc775f45
7
- data.tar.gz: 8903643bc5207ff8f1b4a74188a7582861a67e2dfc698064b47ea4a862f5e9e9e903659e15ff3a99f06eb2f184ff9be154839c7c4b28f9e4b4ab56c61257740f
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
- last_updated = coll.order(:updated_at).last.updated_at.utc rescue 0
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
- self.index_only = index
61
+ cattr_accessor :create_timestamp
62
+ cattr_accessor :update_timestamp
63
+ self.index_only = index
56
64
  self.ranged_matchers = ranged
57
- self.index_search_property = search
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
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "1.29.8"
2
+ VERSION = "1.30.0"
3
3
  end
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.29.8
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-10 00:00:00.000000000 Z
11
+ date: 2014-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday