rails-settings-cached 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/rails-settings/base.rb +1 -3
- data/lib/rails-settings/default.rb +2 -1
- data/lib/rails-settings/extend.rb +2 -2
- data/lib/rails-settings/railtie.rb +1 -1
- data/lib/rails-settings/settings.rb +1 -1
- data/lib/rails-settings/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 944395ff037e8219792760352c87d03acb83c111
|
4
|
+
data.tar.gz: b06a446b00755294b28d807d77aaae1827926031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bca7d11860ccea2577c2f484cac61b16ae5cdc57a639812926a3029c67dcac2e9200eb0091472d275211cf620363088ab8e4489f036eb5f24d332137c4376ed5
|
7
|
+
data.tar.gz: ff2156a8c94b94b47e1327dabc6cf227e8c53b0a60ad9d0690959b030e8ee3cd73c4bf964f269108a2f522bab8a391fdd989819c98591a51027dcbf1828e89bc
|
data/README.md
CHANGED
@@ -259,7 +259,8 @@ app/views/admin/settings/edit.html.erb
|
|
259
259
|
```
|
260
260
|
|
261
261
|
Also you may use [rails-settings-ui](https://github.com/accessd/rails-settings-ui) gem
|
262
|
-
for building ready to using interface with validations
|
262
|
+
for building ready to using interface with validations,
|
263
|
+
or [activeadmin_settings_cached](https://github.com/artofhuman/activeadmin_settings_cached) gem if you use [activeadmin](https://github.com/activeadmin/activeadmin).
|
263
264
|
|
264
265
|
## Use case:
|
265
266
|
|
data/lib/rails-settings/base.rb
CHANGED
@@ -6,7 +6,7 @@ module RailsSettings
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def enabled?
|
9
|
-
source_path && File.
|
9
|
+
source_path && File.exist?(source_path)
|
10
10
|
end
|
11
11
|
|
12
12
|
def source(value = nil)
|
@@ -19,6 +19,7 @@ module RailsSettings
|
|
19
19
|
|
20
20
|
def [](key)
|
21
21
|
# foo.bar.dar Nested fetch value
|
22
|
+
return instance[key] if instance.has_key?(key)
|
22
23
|
keys = key.to_s.split('.')
|
23
24
|
val = instance
|
24
25
|
keys.each do |k|
|
@@ -9,7 +9,7 @@ module RailsSettings
|
|
9
9
|
.select("DISTINCT #{table_name}.*")
|
10
10
|
}
|
11
11
|
|
12
|
-
scope :with_settings_for, lambda
|
12
|
+
scope :with_settings_for, lambda { |var|
|
13
13
|
joins("JOIN settings ON (settings.thing_id = #{table_name}.#{primary_key} AND
|
14
14
|
settings.thing_type = '#{base_class.name}') AND settings.var = '#{var}'")
|
15
15
|
}
|
@@ -20,7 +20,7 @@ module RailsSettings
|
|
20
20
|
.where('settings.id IS NULL')
|
21
21
|
}
|
22
22
|
|
23
|
-
scope :without_settings_for, lambda
|
23
|
+
scope :without_settings_for, lambda { |var|
|
24
24
|
where('settings.id IS NULL')
|
25
25
|
.joins("LEFT JOIN settings ON (settings.thing_id = #{table_name}.#{primary_key} AND
|
26
26
|
settings.thing_type = '#{base_class.name}') AND settings.var = '#{var}'")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module RailsSettings
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
-
initializer
|
3
|
+
initializer 'rails_settings.active_record.initialization' do
|
4
4
|
RailsSettings::Base.after_commit :rewrite_cache, on: %i(create update)
|
5
5
|
RailsSettings::Base.after_commit :expire_cache, on: %i(destroy)
|
6
6
|
end
|
@@ -55,7 +55,7 @@ module RailsSettings
|
|
55
55
|
|
56
56
|
defaults = {}
|
57
57
|
if Default.enabled?
|
58
|
-
defaults = starting_with.nil? ? Default.instance : Default.instance.
|
58
|
+
defaults = starting_with.nil? ? Default.instance : Default.instance.select { |key, _| key.to_s.start_with?(starting_with) }
|
59
59
|
end
|
60
60
|
|
61
61
|
result.reverse_merge! defaults
|
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.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
74
|
+
rubygems_version: 2.4.8
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Settings plugin for Rails that makes managing a table of global keys.
|