artirix_data_models 0.25.0 → 0.26.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: 8dfe7dd5276eb2921d0a32fe3463b24c10469612
4
- data.tar.gz: 487b4f103a49cdb4246bbc641064ad615e58807f
3
+ metadata.gz: 2efa847dc8cfed6755c5717fa582157d2c76a197
4
+ data.tar.gz: 29a9c8eae07e6e058f898e9790d749bdd1c87f62
5
5
  SHA512:
6
- metadata.gz: 9719fa95658855627b87ed6bc69869c71811d8a32734b6fc498bfaefd97d518d540f98e25b56c5407729b682b23164251847cfaeb7b2519fbee9df073152f0c2
7
- data.tar.gz: ae324ff4c952554a354b088735489b6bfd24816dded5110aa2224524888f6a4e227c7ce785856a403ce275604554c10022dff6c322de50c58c79392708b19dc6
6
+ metadata.gz: 72f11738fa0f75510486170c79db846b15257572943b0a22e928b41e1eeea36eb3bbe31fed93e03223645567f2b23e1b98b9bc8404c7e8be081e053b340e72ec
7
+ data.tar.gz: 3ecbdc482c1f817af74808b103202d80029b3c4803b7f87df6a304f43875fab21ef9ff66aa3b7fd90e0c526b08da0071892a00b35bb6dc74fe4c78cd84ac4837
data/README.md CHANGED
@@ -327,6 +327,9 @@ end
327
327
 
328
328
  ## Changes
329
329
 
330
+ ### 0.26.0
331
+ - Expose cache configuration in case the app has config specific for `artirix_cache_service` that we want to use with `ArtirixDataModels.use_cache_service(artirix_cache_service)` where the argument is a `ArtirixCacheService::Service` object.
332
+
330
333
  ### 0.25.0
331
334
  - *IMPORTANT FIX*: prevent infinite loop in Model's `cache_key` method, where if `_timestamp` is nil, it will try to load `updated_at`. If that's not part of the partial mode, it will force a reload, which will get a cache_key, which will ask for `updated_at`, which will force a reload...
332
335
 
@@ -1,27 +1,46 @@
1
1
  module ArtirixDataModels::CacheService
2
+
3
+ def self.service
4
+ @service ||= build_service
5
+ end
6
+
7
+ def self.use_cache_service(artirix_cache_service)
8
+ unless artirix_cache_service.kind_of? ArtirixCacheService::Service
9
+ raise InvalidServiceError, "expected ArtirixCacheService::Service, given #{artirix_cache_service.inspect}"
10
+ end
11
+
12
+ @service = artirix_cache_service
13
+ end
14
+
2
15
  def self.reload_service
3
16
  @service = nil
4
17
  service
5
18
  end
6
19
 
7
- def self.service
8
- @service ||= ArtirixCacheService::Service.new.tap do |service|
9
- prefix = ArtirixDataModels.configuration.try(:cache_app_prefix)
10
- if prefix
11
- service.register_key_prefix "#{prefix}__"
12
- end
20
+ def self.build_service
21
+ ArtirixCacheService::Service.new.tap do |service|
22
+ set_key_prefix_from_config(service)
23
+ set_options_from_config(service)
24
+ end
25
+ end
13
26
 
14
- options = ArtirixDataModels.configuration.try(:cache_options)
15
- if options
16
- options.each do |name, opts|
17
- if name.to_s == 'default_options'
18
- service.register_default_options opts
19
- else
20
- service.register_options name, opts
21
- end
27
+ def self.set_key_prefix_from_config(service)
28
+ prefix = ArtirixDataModels.configuration.try(:cache_app_prefix)
29
+ if prefix
30
+ service.register_key_prefix "#{prefix}__"
31
+ end
32
+ end
33
+
34
+ def self.set_options_from_config(service)
35
+ options = ArtirixDataModels.configuration.try(:cache_options)
36
+ if options
37
+ options.each do |name, opts|
38
+ if name.to_s == 'default_options'
39
+ service.register_default_options opts
40
+ else
41
+ service.register_options name, opts
22
42
  end
23
43
  end
24
-
25
44
  end
26
45
  end
27
46
 
@@ -101,4 +120,7 @@ module ArtirixDataModels::CacheService
101
120
  super
102
121
  end
103
122
  end
123
+
124
+ class InvalidServiceError < StandardError
125
+ end
104
126
  end
@@ -1,3 +1,3 @@
1
1
  module ArtirixDataModels
2
- VERSION = '0.25.0'
2
+ VERSION = '0.26.0'
3
3
  end
@@ -133,6 +133,10 @@ module ArtirixDataModels
133
133
  @disabled_cache ||= DisabledCache.new
134
134
  end
135
135
 
136
+ def self.use_cache_service(artirix_cache_service)
137
+ CacheService.use_cache_service artirix_cache_service
138
+ end
139
+
136
140
  # CONFIGURATION
137
141
 
138
142
  def self.configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artirix_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Turiño
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport