active_tools 0.0.15 → 0.0.16

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
  SHA1:
3
- metadata.gz: 8bdb8683fdb26bd3ed759e298a7e0b667b465c27
4
- data.tar.gz: 635db4c7f1ff33da17f7c1f801524ea41e70510a
3
+ metadata.gz: 249bc84738b736bbeb3e1d65bbded3ce140f624a
4
+ data.tar.gz: 02a900d5bb6f25876560c7d9672eb300b33f5245
5
5
  SHA512:
6
- metadata.gz: 03b46223cbd38960d99532a4f2ec580a7f330ae4ab61d47fa0bfdccc3c84f4a2498c2b476fbd361f86568a610ae4989c91e25d78f09f3be1cf69d86fadd37454
7
- data.tar.gz: edb7a4550fda0fd9800e270b2186833a83bf8a4c47b9a80cbe479ab388a0209937c6baedd6f6308e7c656a81169a331418b4ef605f1737d29e202bc91f65d81c
6
+ metadata.gz: 36d73460fe8ea74b1bb0e09c53d0577f942e5bb422108937086d38c2fccb62e69999290d54c1e6ebc833aa7979313cf923093495dc82c57f1cc7a9e576a985b8
7
+ data.tar.gz: a157672e10e3f118b3a6ed297c0d478c0ba807b858902646769672bd713105a464a5e4e2841aaf4fdb2afea0f55f066b15e3bd6e0fe9978afba41a2d20831b1a
@@ -0,0 +1,36 @@
1
+ module ActiveTools
2
+ module CoreExtension
3
+ module RuntimeCaching
4
+ def acts_as_runtime_caching(*args)
5
+ options = args.extract_options!
6
+ accessors = args
7
+ thread_key = options[:thread_key]||::SecureRandom.urlsafe_base64(nil, false).to_sym
8
+ send(:include, ::Singleton)
9
+ container = Class.new
10
+ container.send(:include, ::ActiveSupport::Configurable)
11
+ container.instance_eval do
12
+ config_accessor *accessors
13
+ end
14
+ define_method :config do
15
+ ::Thread.current[thread_key] ||= container.new
16
+ end
17
+ define_method :"config=" do |value|
18
+ ::Thread.current[thread_key] = value
19
+ end
20
+ accessors.each do |method|
21
+ instance_eval <<-DELEGATORS
22
+ def #{method}
23
+ instance.config.#{method}
24
+ end
25
+
26
+ def #{method}=(value)
27
+ instance.config.#{method} = (value)
28
+ end
29
+ DELEGATORS
30
+ end
31
+ end
32
+
33
+ ::Class.send(:include, RuntimeCaching)
34
+ end
35
+ end
36
+ end
@@ -8,6 +8,7 @@ require 'active_tools/core_extension/method_digger'
8
8
  require 'active_tools/core_extension/concat_conditions'
9
9
  require 'active_tools/core_extension/string_indent'
10
10
  require 'active_tools/core_extension/string_round_with'
11
+ require 'active_tools/core_extension/runtime_caching'
11
12
 
12
13
  module ActiveTools
13
14
  module CoreExtension
@@ -1,3 +1,3 @@
1
1
  module ActiveTools
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valery Kvon
@@ -92,6 +92,7 @@ files:
92
92
  - lib/active_tools/core_extension/kabuki/zip.rb
93
93
  - lib/active_tools/core_extension/merge_hashup.rb
94
94
  - lib/active_tools/core_extension/method_digger.rb
95
+ - lib/active_tools/core_extension/runtime_caching.rb
95
96
  - lib/active_tools/core_extension/send_if.rb
96
97
  - lib/active_tools/core_extension/string_indent.rb
97
98
  - lib/active_tools/core_extension/string_round_with.rb