blueprint_config 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blueprint_config/backend/active_record.rb +15 -2
- data/lib/blueprint_config/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec591307b09bd72ebe07601ae537938479fa70561e82127a468b7e0028e4df8
|
4
|
+
data.tar.gz: 4ac393929bbf592a95e4196cbb195cd7d463e80f4ba6df4fce8c99b74967e330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17467c0fd7172bf30880be1a40c1564c7f4271df3f388537f31986682f950766cea2ef3969061d5e7e2f68b1935dcddc930bff9151815be09be6ffcc1cca6bc8
|
7
|
+
data.tar.gz: 890305e747d5314fcd1d9fc13e0eeaec4d931930483ef39898f44df9105f17f5e4e191b5a1f76eb907bc00647668ceb42b2ded7dc6051c476e43fc37d458b200
|
@@ -11,7 +11,7 @@ module BlueprintConfig
|
|
11
11
|
=======================================================================
|
12
12
|
Settings table not found. Please add the configuration table by running:
|
13
13
|
|
14
|
-
rails generate
|
14
|
+
rails generate blueprint_config:install
|
15
15
|
rake db:migrate
|
16
16
|
=======================================================================
|
17
17
|
WARNING
|
@@ -20,16 +20,27 @@ module BlueprintConfig
|
|
20
20
|
@options = options
|
21
21
|
@updated_at = nil
|
22
22
|
@last_checked_at = nil
|
23
|
-
@
|
23
|
+
@configured = true
|
24
|
+
@mutex = Thread::Mutex.new
|
24
25
|
end
|
25
26
|
|
26
27
|
def load_keys
|
28
|
+
@configured = true
|
27
29
|
update_timestamp
|
28
30
|
|
29
31
|
data = Setting.all.map { |s| { s.key => s.parsed_value } }.reduce(:merge) || {}
|
30
32
|
return data.transform_keys(&:to_sym) unless @options[:nest]
|
31
33
|
|
32
34
|
nest_hash(data, @options[:nest_separator] || '.')
|
35
|
+
rescue ::ActiveRecord::NoDatabaseError => e
|
36
|
+
# database is not created yet
|
37
|
+
@configured = false
|
38
|
+
{}
|
39
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
40
|
+
@configured = false
|
41
|
+
Rails.logger.warn(e.message)
|
42
|
+
Rails.logger.warn(MISSING_TABLE_WARNING)
|
43
|
+
{}
|
33
44
|
end
|
34
45
|
|
35
46
|
def update_timestamp
|
@@ -39,6 +50,8 @@ module BlueprintConfig
|
|
39
50
|
end
|
40
51
|
|
41
52
|
def fresh?
|
53
|
+
# if database is not create/configured yet - don't try to refresh settings from it
|
54
|
+
return true if !@configured
|
42
55
|
return true if @last_checked_at.present? && @last_checked_at > 1.second.ago
|
43
56
|
|
44
57
|
@mutex.synchronize do
|