activekit 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98f08d0d1d37f5f2e3968da22af8cb3feb20704f5f5f6c6cf02d838fd2560354
4
- data.tar.gz: ee3805f8d06d399c9519d0ae0360ee07f1069400033638eea6c2f9cfce519aac
3
+ metadata.gz: c2a8a1118c555e7d450d530a4d844e43d718acf3c879c5e21616e2607c46bd7e
4
+ data.tar.gz: 838dd18ff937255d7f860ad0279f886123de8367ae9182cd3f93d1bf6dcbd829
5
5
  SHA512:
6
- metadata.gz: 6dc11428da73f1875bec2250f402df9e67053903b5b6c1762190fcf72f3c16d8f76f42c34bfcd34d9b9b5ecdf534d8d71d6bafbcd059dfe1c968652bfc8490f2
7
- data.tar.gz: 73521d96b3200bbeaae1edda274ed4eff23154b66c8206b888b3ce540eb55d92a351925c628e4e4bcbbcfe3f007a23a945e12fbda6581c233d199b7a26150cae
6
+ metadata.gz: 9f5946fd34c134e6b0b11e70a3c5f307dc4c83d77bcfd11003e6d7aeddce7772202ba96d13e3638060d313231ee7390c6dd80a0d9d23de11ed2e10e54ba97b96
7
+ data.tar.gz: 171003ab2c3b2c8e4f9c8f098c5b5811cf2e3e6dd9d2315658bbdfaa1beaea0b7ce3551d60bad7bd9425b39783d570236f43cd25cb5e67c0084e9ed5b7ffc5cb
@@ -18,11 +18,12 @@ module ActiveKit
18
18
 
19
19
  wordbook = Wordbook.new
20
20
  word_for_position = wordbook.next_word(count: position)
21
- json_where = 'value->"$.sequence.attributes.' + attribute_name.to_s + '" = "' + word_for_position + '"'
22
- record_at_position = ActiveKit::Attribute.where(record_type: record.class.name).where(json_where).first&.record
21
+ # TODO: committer record for the attribute with given word_for_position should be found and resaved to recalculate its position.
22
+ # json_where = 'value->"$.sequence.attributes.' + attribute_name.to_s + '" = "' + word_for_position + '"'
23
+ # record_at_position = ActiveKit::Attribute.where(record_type: record.class.name).where(json_where).first&.record
23
24
  record.activekit_association.sequence[:attributes][attribute_name.to_sym] = word_for_position
24
25
  record.activekit_association.save!
25
- record_at_position.save! if record_at_position
26
+ # record_at_position.save! if record_at_position
26
27
  else
27
28
  record.activekit_association.sequence[:attributes][attribute_name.to_sym] = nil
28
29
  record.activekit_association.save!
@@ -33,7 +33,7 @@ module ActiveKit
33
33
  updater = options.dig(:updater) || {}
34
34
 
35
35
  if updater.empty?
36
- after_commit do
36
+ after_save do
37
37
  position = positioning_method ? self.public_send(positioning_method) : nil
38
38
  self.class.activekiter.sequence.update(record: self, attribute_name: attribute_name, position: position)
39
39
  logger.info "ActiveSequence - Sequencing from #{self.class.name}: Done."
@@ -49,7 +49,10 @@ module ActiveKit
49
49
  base_klass = search_base_klass(self.name, updater_via)
50
50
  klass = reflected_klass(base_klass, updater_on.keys.first)
51
51
  klass.constantize.class_eval do
52
- after_commit do
52
+ after_save :activekit_sequence_sequenceable_callback
53
+ after_destroy :activekit_sequence_sequenceable_callback
54
+
55
+ define_method :activekit_sequence_sequenceable_callback do
53
56
  inverse_assoc = self.class.search_inverse_assoc(self, updater_on)
54
57
  position = positioning_method ? self.public_send(positioning_method) : nil
55
58
  if inverse_assoc.respond_to?(:each)
@@ -59,6 +62,7 @@ module ActiveKit
59
62
  end
60
63
  logger.info "ActiveSequence - Sequencing from #{self.class.name}: Done."
61
64
  end
65
+ private :activekit_sequence_sequenceable_callback
62
66
  end
63
67
  end
64
68
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveKit
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activekit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - plainsource
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails