activekit 0.2.0 → 0.2.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: 98f08d0d1d37f5f2e3968da22af8cb3feb20704f5f5f6c6cf02d838fd2560354
4
- data.tar.gz: ee3805f8d06d399c9519d0ae0360ee07f1069400033638eea6c2f9cfce519aac
3
+ metadata.gz: 67eb8f62ef1b3e4f6532c5431730922130158646b4067ed14511314777d18448
4
+ data.tar.gz: 11d7429b7011c2aca230935789489c4ac6828ff60e4cb250fe18910fd14d2daf
5
5
  SHA512:
6
- metadata.gz: 6dc11428da73f1875bec2250f402df9e67053903b5b6c1762190fcf72f3c16d8f76f42c34bfcd34d9b9b5ecdf534d8d71d6bafbcd059dfe1c968652bfc8490f2
7
- data.tar.gz: 73521d96b3200bbeaae1edda274ed4eff23154b66c8206b888b3ce540eb55d92a351925c628e4e4bcbbcfe3f007a23a945e12fbda6581c233d199b7a26150cae
6
+ metadata.gz: 63885175b26d2bace31dd3ded154ab4631819645f4c2cc41653e57179968f03149f2f352c399c9693bb69bbc476e322f3c7ef67e9e4f159e956111bc478fde7c
7
+ data.tar.gz: fdd159ca5f30a970452036b5d8fd8eb384466dc908c166b7873144a2cee0f3c6cd8b671b23813db22073b389dbb916469576c8eef3cd0a44d1ca80e844507372
@@ -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
+ private def activekit_sequence_sequenceable_callback
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)
@@ -1,3 +1,3 @@
1
1
  module ActiveKit
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
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.1
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