coactive 0.4.0 → 0.4.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: 55895695a2ad27b38fd2ca9f1d8c38b1135975cd3e3ff41fe3f7e53b4564c5ba
4
- data.tar.gz: e51d7e8e74748cd29284e9795d199c7fe9b2737ecdc79f57412632114c3bdee8
3
+ metadata.gz: b15dae4695420734d0486669dd7f88d7eeceb8815932dc5f47d37cedf0dd4c61
4
+ data.tar.gz: cd7f7aae30957f69c76230b8cb97ca846ad4d4c99f6c02045f54b9c866d2ec68
5
5
  SHA512:
6
- metadata.gz: 92e2fbe3d500452f8b9584174e2f34c9383b03e12b2eb70d58324caf5ba48b793bb86d6f8153f5a54c454141e1dd223825d1d3fd1ad1c6b8f0c375a5a2c40a8d
7
- data.tar.gz: c9c6da5d6f236221af0f20927eeff9c4846a3ef5cb3940c481a0409842d98186b778b772f777589743d525b2f0914206ef41206530a3043e91098663e937fafe
6
+ metadata.gz: eebff4ac3fdb067eb44a59ffc634e4fdda567663e6be2c30923828a311f29a52679ea2aaf3295e17412ee492ef3705c1ff200a0065f5bfee03bbf36a045dd007
7
+ data.tar.gz: e94206eda575c397edc5686fe012cf7ebd66074fa74b1a4215c733d7462b01099a9e2d537041749a039bcfe079bbf4ade6c71d4c2a249e65fa2849175ed94532
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.4.1
4
+
5
+ * Clear registry of coactions when reloaded.
6
+
3
7
  ## 0.4.0
4
8
 
5
9
  * Improve lookup performance for named coactors.
@@ -6,16 +6,26 @@ module Coactive
6
6
  module Coactions
7
7
  extend ActiveSupport::Concern
8
8
 
9
- included do
10
- class_attribute :coactions_map
11
- self.coactions_map = {}
9
+ class << self
10
+ class_attribute :registry
11
+ self.registry = {}
12
+
13
+ def [](base, name)
14
+ registry.dig(base, name)
15
+ end
16
+
17
+ def []=(base, name, array)
18
+ registry[base] ||= {}
19
+ registry[base][name] = array
20
+ end
12
21
  end
13
22
 
14
23
  class_methods do
15
24
  def coaction(*names, **options)
25
+ base = coactive_config.base_class
16
26
  names.each do |name|
17
- coactions = coactions_map[name].to_a + [Coaction.new(self, name, options)]
18
- coactions_map[name] = coactions.sort_by.with_index { |coaction, i| [coaction.priority, i] }
27
+ coactions = Coactions[base, name].to_a + [Coaction.new(self, name, options)]
28
+ Coactions[base, name] = coactions.sort_by.with_index { |coaction, i| [coaction.priority, i] }
19
29
  end
20
30
  end
21
31
  end
@@ -11,11 +11,11 @@ module Coactive
11
11
  private
12
12
 
13
13
  def load_files
14
- Coactive::Loader.call(@config.load_paths)
14
+ Loader.call(@config.load_paths)
15
15
  end
16
16
 
17
17
  def lookup
18
- @config.base_class.coactions_map[@coactant].to_a.map(&:coactor)
18
+ Coactions[@config.base_class, @coactant].to_a.map(&:coactor)
19
19
  end
20
20
 
21
21
  class << self
@@ -5,6 +5,7 @@ module Coactive
5
5
  ActiveSupport::Reloader.to_prepare do
6
6
  Coactive::Loader.loaded.clear
7
7
  Coactive::Lookup.cache.clear
8
+ Coactive::Coactions.registry.clear
8
9
  end
9
10
  end
10
11
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coactive
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshikazu Kaneta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-10 00:00:00.000000000 Z
11
+ date: 2023-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport