rails-settings-cached 0.4.6 → 0.5.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: 74658f0058bdd7f5c96c897aa50a4bf73fef6187
4
- data.tar.gz: 843c92f5f05be95d6fc35448341aea6e0accdc1c
3
+ metadata.gz: e5ff4437eeee1b3c42d9f0a38b5465f79d40543e
4
+ data.tar.gz: 71914cc7e2c4fd70d30388d66c376580099103dc
5
5
  SHA512:
6
- metadata.gz: 605187ee81edded5b280197db001e17d6cc8a7b267aba5af28cd22aad8aa5ab541f4dc7e4ac68d9a8f5adde4dd946c26cec1261a10b6aded2bece4fadc2d0cc4
7
- data.tar.gz: 0dbe54e18c5ed5e7d0f6d0ec6bacd56e774a6a4e3d7b4dba9329a11c6cb649cf6b9f89e60fbee9df9f098abd36801ca3b32efaaaa1ce0ba721fc97c548b00299
6
+ metadata.gz: 4b1af6234a929ea919d40f768e82ef48b7232906680e7185673011b9275c789225025797982ea5a964848b33f274813e2ffba4ed4bfdf77e9d13d8dd3e3d54ee
7
+ data.tar.gz: d73891ca6c1fb5f194856074209c2c2256588ef9a253fdd870440122ae9c5df427dd4ce9002100dfc209da3a69e7dad3739274f6edaf243dd99c4d9aa6b905f4
data/README.md CHANGED
@@ -149,7 +149,7 @@ user.settings.all
149
149
  # { "color" => :red }
150
150
  ```
151
151
 
152
- I you want to find users having or not having some settings, there are named scopes for this:
152
+ If you want to find users having or not having some settings, there are named scopes for this:
153
153
 
154
154
  ```ruby
155
155
  User.with_settings
@@ -165,6 +165,15 @@ User.without_settings('color')
165
165
  # returns a scope of users having no 'color' setting (means user.settings.color == nil)
166
166
  ```
167
167
 
168
+ Settings maybe dynamically scoped. For example, if you're using [apartment gem](https://github.com/influitive/apartment) for multitenancy, you may not want tenants to share settings:
169
+
170
+ ```ruby
171
+ class Settings < RailsSettings::CachedSettings
172
+ cache_prefix { Apartment::Tenant.current }
173
+ ...
174
+ end
175
+ ```
176
+
168
177
  -----
169
178
 
170
179
  ## How to create a list, form to manage Settings?
@@ -13,8 +13,13 @@ module RailsSettings
13
13
  end
14
14
 
15
15
  class << self
16
+ def cache_prefix(&block)
17
+ @cache_prefix = block
18
+ end
19
+
16
20
  def cache_key(var_name, scope_object)
17
21
  scope = "rails_settings_cached:"
22
+ scope << "#{@cache_prefix.call}:" if @cache_prefix
18
23
  scope << "#{scope_object.class.name}-#{scope_object.id}:" if scope_object
19
24
  scope << "#{var_name}"
20
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-settings-cached
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Squeegy
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-09-29 00:00:00.000000000 Z
14
+ date: 2015-10-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.4.7
120
+ rubygems_version: 2.4.8
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: This is improved from rails-settings, added caching. Settings is a plugin
@@ -127,4 +127,3 @@ summary: This is improved from rails-settings, added caching. Settings is a plug
127
127
  into your rails app. You can store any kind of object. Strings, numbers, arrays,
128
128
  or any object. Ported to Rails 3!
129
129
  test_files: []
130
- has_rdoc: