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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bce2b99239c2fbded5d529b7f225806c206e44f6
4
- data.tar.gz: 7a069f5b6bb5d95d8f280618997a3f65f4730370
3
+ metadata.gz: 944395ff037e8219792760352c87d03acb83c111
4
+ data.tar.gz: b06a446b00755294b28d807d77aaae1827926031
5
5
  SHA512:
6
- metadata.gz: b42abe0ebe5799e0ac1dc0cf80029d6213284647befb0139e2df75e4ffe2e1e4064245b84a99548b387391f3ad5131cbbe6fd80bceb356bfb148008b29611fa6
7
- data.tar.gz: e5235b9c6f0f958cdddec08359efd1c80e41359f719287fa8a33d5e06c10c135c1dc48a36450024f7e828d890aea01867454d1a8fce4a2632050542a5257119a
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
 
@@ -42,9 +42,7 @@ module RailsSettings
42
42
  # set a setting value by [] notation
43
43
  def []=(var_name, value)
44
44
  super
45
-
46
- Rails.cache.write(cache_key(var_name, @object),value)
47
-
45
+ Rails.cache.write(cache_key(var_name, @object), value)
48
46
  value
49
47
  end
50
48
 
@@ -6,7 +6,7 @@ module RailsSettings
6
6
 
7
7
  class << self
8
8
  def enabled?
9
- source_path && File.exists?(source_path)
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 { |var|
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 { |var|
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 "rails_settings.active_record.initialization" do
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.fetch(starting_with, {})
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
@@ -1,7 +1,7 @@
1
1
  module RailsSettings
2
2
  class << self
3
3
  def version
4
- '0.6.4'
4
+ '0.6.5'
5
5
  end
6
6
  end
7
7
  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.6.4
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-05-23 00:00:00.000000000 Z
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.5.1
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.