web47core 0.7.1 → 0.7.7

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: 9f1bb05a864b2fba4e1d35563c71958ade83637d8881843a26430027e8c3878f
4
- data.tar.gz: 4e39e3f4064f9d81fb4636f20eae6326e7d84e5a206adb57ba9fb6c601723efe
3
+ metadata.gz: 13c5bfc15e45ddc49167d2f71c698abe48c22d7b974ba18096509bc9d9288118
4
+ data.tar.gz: a8f8f18537be2bf61f7ce7e7bae6b1b552f9dfd51314c250be663971bc355855
5
5
  SHA512:
6
- metadata.gz: 1d2855e00108d8d40c7a4fb6d976ae621d7eb8be6ba1530f0260457d032a7227dc695fce39796af5d101ef0a0ddb1a5adc11c46f4a4e825ccee7724ddcc54855
7
- data.tar.gz: 71b746532f35a9439b2b3816ec6e64c26079e4e72bcad370c6726407492543231c8962c1a0229e4bcb16b60bf9197bea5c1995cf8dddc2efadc81386eb9b338c
6
+ metadata.gz: c988580b2939046e514b84e517998a36e2d6f87ed4b9a2388f3ab3f04f55dec4c9cf6cb2215407f92d5ea49999f631c4e02ad5a373ae293e53ca37307e8fd91f
7
+ data.tar.gz: 84291d6a8153f65b925e9f280b7152f3b2396520fee0c87f40f382f6a223d5bf0e927e3a85e9838ebc460939280974b54bbed4cac23ceba0957301eee311e4cc
@@ -60,15 +60,16 @@ module CoreHelper
60
60
  # 3. Length 5-10 only show the first and last character
61
61
  # 4. Otherwise show the first and last three characters
62
62
  def mask_value(value, default: '************')
63
- return default if value.blank?
63
+ return default if value.blank? || !value.respond_to?(:to_s)
64
64
 
65
- case value.length
65
+ string_value = value.to_s
66
+ case string_value.length
66
67
  when 1..4
67
- "#{value.first}***********"
68
+ "#{string_value.first}***********"
68
69
  when 5..10
69
- "#{value.first}**********#{value.last}"
70
+ "#{string_value.first}**********#{string_value.last}"
70
71
  else
71
- "#{value[0..2]}**********#{value[-3..-1]}"
72
+ "#{string_value[0..2]}**********#{string_value[-3..-1]}"
72
73
  end
73
74
  end
74
75
 
@@ -75,11 +75,7 @@ module CoreSystemConfiguration
75
75
 
76
76
  module ClassMethods
77
77
  def configuration
78
- @configuration ||= SystemConfiguration.find_or_create_by!(environment: Rails.env)
79
- end
80
-
81
- def reset
82
- @configuration = nil
78
+ SystemConfiguration.find_or_create_by!(environment: Rails.env)
83
79
  end
84
80
 
85
81
  def smtp_configuration
@@ -249,13 +245,4 @@ module CoreSystemConfiguration
249
245
  def slack_configured?
250
246
  slack_api_url.present?
251
247
  end
252
-
253
- # private
254
-
255
- #
256
- # Clear the cache when the object is saved
257
- #
258
- # def clear_cache
259
- # Rails.cache.delete "SystemConfiguration::#{Rails.env}"
260
- # end
261
248
  end
@@ -22,9 +22,9 @@ module StandardModel
22
22
  #
23
23
  # Relationships
24
24
  #
25
- belongs_to :last_modified_by, class_name: Web47core::Config.audit_model_class_name, optional: true
26
- belongs_to :created_by, class_name: Web47core::Config.audit_model_class_name, optional: true
27
- has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify
25
+ belongs_to :last_modified_by, polymorphic: true, dependent: :nullify, optional: true
26
+ belongs_to :created_by, polymorphic: true, dependent: :nullify, optional: true
27
+ has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify, inverse_of: :model
28
28
  #
29
29
  # Callbacks
30
30
  #
@@ -98,9 +98,10 @@ module StandardModel
98
98
  # Record the creation with this user
99
99
  #
100
100
  def create_and_log(user, attributes)
101
- attributes[:last_modified_by_id] = user.id
102
- attributes[:created_by_id] = user.id
103
101
  model = create(attributes)
102
+ model.last_modified_by = user
103
+ model.created_by = user
104
+ model.save
104
105
  log_change(user, model, attributes) if model.valid?
105
106
  model
106
107
  end
@@ -109,9 +110,10 @@ module StandardModel
109
110
  # Record the creation with this user
110
111
  #
111
112
  def create_and_log!(user, attributes)
112
- attributes[:last_modified_by_id] = user.id
113
- attributes[:created_by_id] = user.id
114
113
  model = create!(attributes)
114
+ model.last_modified_by = user
115
+ model.created_by = user
116
+ model.save!
115
117
  log_change(user, model, attributes)
116
118
  model
117
119
  end
@@ -209,7 +211,7 @@ module StandardModel
209
211
  return self if attributes.blank?
210
212
 
211
213
  action = audit_action
212
- attributes[:last_modified_by_id] = user.id
214
+ self.last_modified_by = user
213
215
  result = update(attributes)
214
216
  log_change(user, attributes, action) if valid?
215
217
  result
@@ -224,7 +226,7 @@ module StandardModel
224
226
  return self if attributes.blank?
225
227
 
226
228
  action = audit_action
227
- attributes[:last_modified_by_id] = user.id
229
+ self.last_modified_by = user
228
230
  result = update!(attributes)
229
231
  log_change(user, attributes, action)
230
232
  result
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Web47core
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.7'
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.1
4
+ version: 0.7.7
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-09 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport