rails-settings-cached 0.6.1 → 0.6.2

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: 77ee4761ccc2fa3dcd3b594e8de0878dfff7737c
4
- data.tar.gz: 453fbd403e16fd91823f64853c209e9742c20ef2
3
+ metadata.gz: 814ca9dffbaac78275816924d159c1eda85a5031
4
+ data.tar.gz: 8dc29d44e8b5aa3c5f10a3fc4fe46943f25d04d5
5
5
  SHA512:
6
- metadata.gz: 498d13784837ecb3ad5b9ee48ff73a9ca19acb0086a950179c34e8c130056aa02af31ef3acab41a0e67eb715d41462b64cdec206bdeb35222b7562f3354c4de2
7
- data.tar.gz: 4a054dedbd4d73dcdb571e658e9ecc82dcb0a0e1d56f0e948040d8b57c0416879183cac1937fa2b99e5c00a2a284099fba1dfb93276007094b552fe08e9c17ac
6
+ metadata.gz: 4ec4e326eecb245cb60b88402e0c6e6f9bf33c5499e5cfe1ca5bbab0a5a8136c572e38e4e870f9fdc02ff6f01cfa1a66a7ba71b2c7a4bf7b4bd1854a195584c6
7
+ data.tar.gz: 28209a07180e319b2f64d555e676c52be74b12c25f01d71be8a6a4b4803ce02d468fee4f3ab9e19097ebe04a2b78a88bae675935529c0223643890e82002a0f6
@@ -4,13 +4,8 @@ require_relative 'rails-settings/cached_settings'
4
4
  require_relative 'rails-settings/scoped_settings'
5
5
  require_relative 'rails-settings/default'
6
6
  require_relative 'rails-settings/extend'
7
+ require_relative 'rails-settings/railtie'
7
8
  require_relative 'rails-settings/version'
8
9
 
9
10
  module RailsSettings
10
- class Railtie < Rails::Railtie
11
- initializer "rails_settings.active_record.initialization" do
12
- RailsSettings::Base.after_commit :rewrite_cache, on: %i(create update)
13
- RailsSettings::Base.after_commit :expire_cache, on: %i(destroy)
14
- end
15
- end
16
11
  end
@@ -30,6 +30,7 @@ module RailsSettings
30
30
  end
31
31
 
32
32
  def [](key)
33
+ return super(key) unless rails_initialized?
33
34
  val = Rails.cache.fetch(cache_key(key, @object)) do
34
35
  super(key)
35
36
  end
@@ -0,0 +1,8 @@
1
+ module RailsSettings
2
+ class Railtie < Rails::Railtie
3
+ initializer "rails_settings.active_record.initialization" do
4
+ RailsSettings::Base.after_commit :rewrite_cache, on: %i(create update)
5
+ RailsSettings::Base.after_commit :expire_cache, on: %i(destroy)
6
+ end
7
+ end
8
+ end
@@ -104,7 +104,9 @@ module RailsSettings
104
104
  end
105
105
 
106
106
  def object(var_name)
107
- table_exists? && thing_scoped.where(var: var_name.to_s).first
107
+ return nil unless rails_initialized?
108
+ return nil unless table_exists?
109
+ thing_scoped.where(var: var_name.to_s).first
108
110
  end
109
111
 
110
112
  def thing_scoped
@@ -114,6 +116,10 @@ module RailsSettings
114
116
  def source(filename)
115
117
  Default.source(filename)
116
118
  end
119
+
120
+ def rails_initialized?
121
+ Rails.application && Rails.application.initialized?
122
+ end
117
123
  end
118
124
  end
119
125
  end
@@ -1,7 +1,7 @@
1
1
  module RailsSettings
2
2
  class << self
3
3
  def version
4
- "0.6.1"
4
+ "0.6.2"
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.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
@@ -48,6 +48,7 @@ files:
48
48
  - lib/rails-settings/cached_settings.rb
49
49
  - lib/rails-settings/default.rb
50
50
  - lib/rails-settings/extend.rb
51
+ - lib/rails-settings/railtie.rb
51
52
  - lib/rails-settings/scoped_settings.rb
52
53
  - lib/rails-settings/settings.rb
53
54
  - lib/rails-settings/version.rb