web47core 0.7.0 → 0.7.1

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
  SHA256:
3
- metadata.gz: c53f1926c9087f4e9cc6f6037b29401e8b5ec7a7b29bb827228a5865b486db87
4
- data.tar.gz: de8d77e1e2fb118dd40ae5f263ed08b711e370a3ce64f6ebf27d6c5898758162
3
+ metadata.gz: 9f1bb05a864b2fba4e1d35563c71958ade83637d8881843a26430027e8c3878f
4
+ data.tar.gz: 4e39e3f4064f9d81fb4636f20eae6326e7d84e5a206adb57ba9fb6c601723efe
5
5
  SHA512:
6
- metadata.gz: f84fb47a7f6a366b40a4e6d1e3155268caa889ed606b2f5e5d0d629b9992ddc16d2c49814292b36bc448a36788c6480a7a9acf6f476eaef770c2fec66e89cd56
7
- data.tar.gz: 8682ac4e3c691e4bec4c2f2ec8313a4dd8c034c5d926cc76f7ea735c0e56d7eff838b40b68e38405be9d4d5bfc1f16fd1dfee65395d7a4fe17b432a644881d03
6
+ metadata.gz: 1d2855e00108d8d40c7a4fb6d976ae621d7eb8be6ba1530f0260457d032a7227dc695fce39796af5d101ef0a0ddb1a5adc11c46f4a4e825ccee7724ddcc54855
7
+ data.tar.gz: 71b746532f35a9439b2b3816ec6e64c26079e4e72bcad370c6726407492543231c8962c1a0229e4bcb16b60bf9197bea5c1995cf8dddc2efadc81386eb9b338c
@@ -16,6 +16,7 @@ module CoreSystemConfiguration
16
16
  #
17
17
  def self.included(base)
18
18
  base.class_eval do
19
+ attr_accessor :configuration
19
20
  #
20
21
  # Fields
21
22
  #
@@ -73,27 +74,12 @@ module CoreSystemConfiguration
73
74
  end
74
75
 
75
76
  module ClassMethods
76
- #
77
- # Fetch the system configuration based on environment name. First try the rails cache
78
- # if not there, then go to the database.
79
- #
80
- # Also, if an argument error is thrown, then just fetch from the database.
81
- #
82
77
  def configuration
83
- cache_key = "SystemConfiguration::#{Rails.env}"
84
-
85
- begin
86
- config = Rails.cache.fetch(cache_key, expires_in: 90.seconds) do
87
- SystemConfiguration.find_by(environment: Rails.env)
88
- end
89
- rescue StandardError
90
- # This seems to happen in testing relative to Country, when it does, remove
91
- # ourselves from the cache and return the DB entry.
92
- Rails.cache.delete cache_key
93
- config = SystemConfiguration.find_or_create_by!(environment: Rails.env)
94
- end
78
+ @configuration ||= SystemConfiguration.find_or_create_by!(environment: Rails.env)
79
+ end
95
80
 
96
- config.nil? ? SystemConfiguration.create(environment: Rails.env) : config
81
+ def reset
82
+ @configuration = nil
97
83
  end
98
84
 
99
85
  def smtp_configuration
@@ -110,19 +96,21 @@ module CoreSystemConfiguration
110
96
  #
111
97
  # NOTE: Currently ignored Codacy issue: When using 'method_missing', fall back on 'super'
112
98
  #
113
- # rubocop:disable Style/MethodMissingSuper
114
99
  def method_missing(method, *args, &_block)
115
- configuration.send method, *args
100
+ if configuration.respond_to?(method)
101
+ configuration.send(method, *args)
102
+ else
103
+ super
104
+ end
116
105
  end
117
106
 
118
- def respond_to?(method_name, _include_private = false)
119
- SystemConfiguration.fields.include?(method_name)
107
+ def respond_to?(method_name, include_private = false)
108
+ configuration.respond_to?(method_name, include_private) || super
120
109
  end
121
110
 
122
- def respond_to_missing?(method_name, _include_private = false)
123
- SystemConfiguration.fields.include?(method_name)
111
+ def respond_to_missing?(method_name, include_private = false)
112
+ configuration.respond_to?(method_name, include_private) || super
124
113
  end
125
- # rubocop:enable Style/MethodMissingSuper
126
114
  end
127
115
 
128
116
  #
@@ -203,7 +191,7 @@ module CoreSystemConfiguration
203
191
  config = SystemConfiguration.configuration
204
192
  path = if config.zendesk_configured? && user.present?
205
193
  time_now = Time.now.to_i
206
- jti = "#{time_now}/#{rand(36**64).to_s(36)}"
194
+ jti = "#{time_now}/#{rand(36 ** 64).to_s(36)}"
207
195
  payload = { jwt: JWT.encode({ iat: time_now, # Seconds since epoch, determine when this token is stale
208
196
  jti: jti, # Unique token identifier, helps prevent replay attacks
209
197
  name: user.name,
@@ -262,12 +250,12 @@ module CoreSystemConfiguration
262
250
  slack_api_url.present?
263
251
  end
264
252
 
265
- private
253
+ # private
266
254
 
267
255
  #
268
256
  # Clear the cache when the object is saved
269
257
  #
270
- def clear_cache
271
- Rails.cache.delete "SystemConfiguration::#{Rails.env}"
272
- end
258
+ # def clear_cache
259
+ # Rails.cache.delete "SystemConfiguration::#{Rails.env}"
260
+ # end
273
261
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2020-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport