web47core 0.7.6 → 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: e8fbdc0d487e8fbc4f4b49b74603fb12b694a77267caa16e9c36d1f589418e28
4
- data.tar.gz: 3587a074347a1807a3eb139aeb904eeb77394bfc76e754994b312736e8acc348
3
+ metadata.gz: 13c5bfc15e45ddc49167d2f71c698abe48c22d7b974ba18096509bc9d9288118
4
+ data.tar.gz: a8f8f18537be2bf61f7ce7e7bae6b1b552f9dfd51314c250be663971bc355855
5
5
  SHA512:
6
- metadata.gz: 5a324d1aa8cfacc3116268b1f173bd6b396f60b33c5c7e5efeefae85dd668786e603e44edd0c51b9fc299efafa5fe1d0d1cbc4b4d84a1bd1b9fe5c364537fc0f
7
- data.tar.gz: 4139018431239a2edecbdcdb40109951636a6409c367fa4b7f9dea9aae1032ce0b7d01ec2ac348816fcd6e4bfff194491c9cc444f10e486f5ca5cd254a784c99
6
+ metadata.gz: c988580b2939046e514b84e517998a36e2d6f87ed4b9a2388f3ab3f04f55dec4c9cf6cb2215407f92d5ea49999f631c4e02ad5a373ae293e53ca37307e8fd91f
7
+ data.tar.gz: 84291d6a8153f65b925e9f280b7152f3b2396520fee0c87f40f382f6a223d5bf0e927e3a85e9838ebc460939280974b54bbed4cac23ceba0957301eee311e4cc
@@ -22,8 +22,8 @@ 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
25
+ belongs_to :last_modified_by, polymorphic: true, dependent: :nullify, optional: true
26
+ belongs_to :created_by, polymorphic: true, dependent: :nullify, optional: true
27
27
  has_many Web47core::Config.audit_model_log_symbol, dependent: :nullify, inverse_of: :model
28
28
  #
29
29
  # Callbacks
@@ -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.6'
4
+ VERSION = '0.7.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web47core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schroeder