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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d679154119599ad2255adc22653e9fce48d4c517a7894c44b7ab49227a55e50
|
4
|
+
data.tar.gz: 38a941b85b06be67ae89a459bf3897097d326713b4ea77ec91a6c69bbdad98c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
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
|