eac_ruby_utils 0.65.0 → 0.66.0

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: 823da035ba7b8dc287824ac361ede6806dc17dd19aeb1ae2cd4626f3d1883231
4
- data.tar.gz: 44ad34e935574af466a3a3b9eb72859074f58b43759c2355423f7162bab9df66
3
+ metadata.gz: 9d679154119599ad2255adc22653e9fce48d4c517a7894c44b7ab49227a55e50
4
+ data.tar.gz: 38a941b85b06be67ae89a459bf3897097d326713b4ea77ec91a6c69bbdad98c1
5
5
  SHA512:
6
- metadata.gz: a98249defe02854ceb5b865b6ed1c63cb78cf93ec2e70340428dc0a7ebc5f864fddd30f57108b7892959a3bbc9ab9a00c574c73d2e827e59d105f927347df2d0
7
- data.tar.gz: 414b7753c72ea221e05a9b41f2563fe5c01c82025658aae6ca13bd705c791a7c78400c45e0663c7118b24d8007fcd7164c9ad88864a45767f472fa52e31ba99d
6
+ metadata.gz: d30ef6f35aa136aa0611039f44422f8d54cb484599b5577c6773873b2f35709d879e26e3fd8ae984837cea7b71a74d521720204d9adce4f12d8712a9ebd42241
7
+ data.tar.gz: 14fdbded17c439e74aea06d61922318fa1e5221a5587ec995f0c7daefae1dd0d6ca76cd2c7876fbd95b8bcf84c18c397b801d11d44d36e668c42eb0ef60c0e3b
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ class Context
5
+ def current
6
+ optional_current || raise('No elements in context')
7
+ end
8
+
9
+ def optional_current
10
+ stack.last
11
+ end
12
+
13
+ delegate :pop, to: :stack
14
+ delegate :push, to: :stack
15
+
16
+ def on(obj)
17
+ push(obj)
18
+ begin
19
+ yield
20
+ ensure
21
+ pop
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def stack
28
+ @stack ||= []
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/context'
4
+
5
+ module EacRubyUtils
6
+ module Contextualizable
7
+ common_concern
8
+
9
+ module ClassMethods
10
+ def context
11
+ @context ||= ::EacRubyUtils::Context.new
12
+ end
13
+ end
14
+
15
+ module InstanceMethods
16
+ def context
17
+ self.class.context
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/patch'
4
+ require 'eac_ruby_utils/contextualizable'
5
+
6
+ class Module
7
+ # Patches module with [EacRubyUtils::Contextualizable].
8
+ def enable_context
9
+ ::EacRubyUtils.patch(self, ::EacRubyUtils::Contextualizable)
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.65.0'
4
+ VERSION = '0.66.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,6 +100,8 @@ files:
100
100
  - lib/eac_ruby_utils/common_constructor/class_initialize.rb
101
101
  - lib/eac_ruby_utils/common_constructor/instance_initialize.rb
102
102
  - lib/eac_ruby_utils/common_constructor/super_args.rb
103
+ - lib/eac_ruby_utils/context.rb
104
+ - lib/eac_ruby_utils/contextualizable.rb
103
105
  - lib/eac_ruby_utils/core_ext.rb
104
106
  - lib/eac_ruby_utils/custom_format.rb
105
107
  - lib/eac_ruby_utils/envs.rb
@@ -168,6 +170,7 @@ files:
168
170
  - lib/eac_ruby_utils/patches/module.rb
169
171
  - lib/eac_ruby_utils/patches/module/abstract_methods.rb
170
172
  - lib/eac_ruby_utils/patches/module/common_concern.rb
173
+ - lib/eac_ruby_utils/patches/module/context.rb
171
174
  - lib/eac_ruby_utils/patches/module/immutable.rb
172
175
  - lib/eac_ruby_utils/patches/module/listable.rb
173
176
  - lib/eac_ruby_utils/patches/module/patch.rb