coactive 0.1.1 → 0.1.2

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: 770c5f64ad5b2032eb3adcc65af596be49364f39fa75de5febc4ee3213ce9f9b
4
- data.tar.gz: f8efaa56a30c4f4eabcb22b7c4a0d14f9753c4f982a79f5ec9d5a697c86181a6
3
+ metadata.gz: ec350eb0f4e954f1fa493547fcea1bbc8bef66b7968ae5cc56c8d4028136d84a
4
+ data.tar.gz: fb1fd1da81b027631dea81b1a03ee4295837c06bd1ef8332fb355529cf4120cd
5
5
  SHA512:
6
- metadata.gz: 6b9f507b0e3c8f2a55e9151ea868d14a314ef017157746375b068c99ded7803bb8c39295fe880b95523eb8d6a054a5ab0646f17a90362e86dd5616d9277bafd3
7
- data.tar.gz: e8e5146497628c5de49e7d45797dfa377d209053d3a1ba5195ab7425bdef3092ba1721006ae3ffbefc721c152526d11ccef3068acde178a2ec5b308a01235b10
6
+ metadata.gz: 8b5238f3adc94100d21684d3fbec31d917e1ff69a08931a2b7fb11a9380f07b9257a0c17f958633f2cdd0477d3c3b2aa9de3cd97ca3aaa95d0aeac9ee10895f0
7
+ data.tar.gz: d71895d84b2ee93ddc5778e1406b8c3b1aee756eb31f0d01d84c2d4e84f1134595812dc34ab21e4c22ee7868c23e4a6134076ce236b9b04554b51b0002cd4943
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.2
4
+
5
+ * Clear lookup cache when reloaded.
6
+ * Use require_dependency instead of require.
7
+
3
8
  ## 0.1.1
4
9
 
5
10
  * Reassign config data when configured.
@@ -11,7 +11,7 @@ module Coactive
11
11
  engines = [Rails] + Rails::Engine.subclasses.map(&:instance)
12
12
  engines.each do |engine|
13
13
  Dir["#{engine.root}/{#{Array(paths).join(',')}}/**/*.rb"].each do |file|
14
- require file
14
+ require_dependency file
15
15
  end
16
16
  end
17
17
  end
@@ -13,19 +13,19 @@ module Coactive
13
13
  class_attribute :cache
14
14
  self.cache = {}
15
15
 
16
- def call(klass, coactivation)
17
- with_cache(klass, coactivation) do
18
- lookup = lookups.detect { |lookup| lookup.callable?(coactivation) }
19
- lookup.new(klass, coactivation).call if lookup
16
+ def call(klass, coactant)
17
+ with_cache(klass, coactant) do
18
+ lookup = lookups.detect { |lookup| lookup.callable?(coactant) }
19
+ lookup.new(klass, coactant).call if lookup
20
20
  end
21
21
  end
22
22
 
23
23
  private
24
24
 
25
- def with_cache(klass, coactivation)
25
+ def with_cache(klass, coactant)
26
26
  if klass.coactive_config.use_cache
27
27
  self.cache[klass] ||= {}
28
- self.cache[klass][coactivation] ||= yield
28
+ self.cache[klass][coactant] ||= yield
29
29
  else
30
30
  yield
31
31
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coactive
4
+ module Railtie
5
+ ActiveSupport::Reloader.to_prepare do
6
+ Coactive::Lookup.cache.clear
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coactive
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/coactive.rb CHANGED
@@ -2,3 +2,4 @@ require 'active_support'
2
2
 
3
3
  require 'coactive/version'
4
4
  require 'coactive/base'
5
+ require 'coactive/railtie' if defined?(Rails)
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshikazu Kaneta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -129,6 +129,7 @@ files:
129
129
  - lib/coactive/lookups/base.rb
130
130
  - lib/coactive/lookups/name.rb
131
131
  - lib/coactive/lookups/object.rb
132
+ - lib/coactive/railtie.rb
132
133
  - lib/coactive/version.rb
133
134
  homepage: https://github.com/kanety/coactive
134
135
  licenses: []