eac_ruby_utils 0.117.0 → 0.118.0

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: 82c2a8a36a2f001a3de7c0512e08f4fa9ca7b26b690cc264a682c52b5dc7e1fd
4
- data.tar.gz: 605b80b24ca686a9d6775fe19a3652619817dc075eb0d6285621bbe4abdabf0f
3
+ metadata.gz: d347508b33322d9d82484d96686d08509dcd783a66f6d1e08338b6ceb9e529b3
4
+ data.tar.gz: abff928219c0f5a3a56b6d59f3ec2bc03d9d6966a276aae84c71c4feef55b1dc
5
5
  SHA512:
6
- metadata.gz: '00179145dcc8ebc905fe2a8a06b72a27c9d97fed906205c39d30f7de8719262d65f1fde1aec6e585d9d19e916c050302ad0e138dacb6a383ee1ac50b916f7851'
7
- data.tar.gz: 81d90fa7a83eff36436bc30951ff163a3edb23a8f86e0fe020e2abb7bf4bdba08de459c12bb90022cf0f615a8857786934dc17fa8594ba86f22f397961db1f34
6
+ metadata.gz: 50463f86cce28d4fbdf01d54e96618b07b02626e8fa2f11301191b4d8ae247be225137eeaab67c856e7ac41267594766859eea751d22adf8507e1798b14f861c
7
+ data.tar.gz: b1e89b2d8e43e1e2e47f065bf9c6b88b9c76cb70235c361abb220239cebbcaa5288782f1b466dba1f902e0cd529e24577ccbe57d8d49fda7ed2ce85bdbe58fe4
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/module/introspection'
4
+ require 'eac_ruby_utils/patches/class/common_constructor'
5
+ require 'eac_ruby_utils/patches/module/module_parent'
6
+ require 'eac_ruby_utils/patches/string/inflector'
7
+
8
+ module EacRubyUtils
9
+ class ActsAsInstanceMethod
10
+ common_constructor :method_class
11
+
12
+ # @param sender_module [Module, nil]
13
+ # @return [self]
14
+ def setup(sender_module = nil)
15
+ sender_module ||= default_sender_module
16
+ the_setup = self
17
+ sender_module.define_method(method_name) do |*args, &block|
18
+ the_setup.method_class.new(self, *args, &block).result
19
+ end
20
+
21
+ self
22
+ end
23
+
24
+ # @return [String]
25
+ def method_name
26
+ method_class.name.demodulize.underscore.variableize
27
+ end
28
+
29
+ # @return [Module]
30
+ def default_sender_module
31
+ method_class.module_parent
32
+ end
33
+ end
34
+ end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/module/introspection'
3
+ require 'eac_ruby_utils/acts_as_instance_method'
4
4
  require 'eac_ruby_utils/patches/class/common_constructor'
5
5
  require 'eac_ruby_utils/patches/module/common_concern'
6
- require 'eac_ruby_utils/patches/module/module_parent'
7
- require 'eac_ruby_utils/patches/string/inflector'
8
6
 
9
7
  module EacRubyUtils
10
8
  module MethodClass
@@ -12,24 +10,18 @@ module EacRubyUtils
12
10
  ::EacRubyUtils::MethodClass::Setup.new(self)
13
11
  end
14
12
 
15
- class Setup
16
- common_constructor :method_class, :static_method, default: [false] do
13
+ class Setup < ::EacRubyUtils::ActsAsInstanceMethod
14
+ common_constructor :method_class, :static_method, default: [false],
15
+ super_args: -> { [method_class] } do
17
16
  perform
18
17
  end
19
18
 
20
19
  def perform
21
- the_setup = self
22
- sender_module.define_method(method_name) do |*args, &block|
23
- the_setup.method_class.new(self, *args, &block).result
24
- end
20
+ setup
25
21
  end
26
22
 
27
- def method_name
28
- method_class.name.demodulize.underscore.variableize
29
- end
30
-
31
- def sender_module
32
- r = method_class.module_parent
23
+ def default_sender_module
24
+ r = super
33
25
  r = r.singleton_class if static_method
34
26
  r
35
27
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/acts_as_instance_method'
4
+
5
+ class Module
6
+ # @return [EacRubyUtils::ActsAsInstanceMethod]
7
+ def acts_as_instance_method
8
+ ::EacRubyUtils::ActsAsInstanceMethod.new(self).setup
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.117.0'
4
+ VERSION = '0.118.0'
5
5
  end
@@ -40,7 +40,7 @@ module EacRubyUtils
40
40
 
41
41
  load(object)
42
42
  true
43
- rescue ::Psych::SyntaxError
43
+ rescue ::Psych::Exception
44
44
  false
45
45
  end
46
46
 
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.117.0
4
+ version: 0.118.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: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -139,6 +139,7 @@ files:
139
139
  - lib/eac_ruby_utils/acts_as_immutable/hash_accessor.rb
140
140
  - lib/eac_ruby_utils/acts_as_immutable/instance_methods.rb
141
141
  - lib/eac_ruby_utils/acts_as_immutable/set_accessor.rb
142
+ - lib/eac_ruby_utils/acts_as_instance_method.rb
142
143
  - lib/eac_ruby_utils/arguments_consumer.rb
143
144
  - lib/eac_ruby_utils/bit.rb
144
145
  - lib/eac_ruby_utils/bit_array.rb
@@ -243,6 +244,7 @@ files:
243
244
  - lib/eac_ruby_utils/patches/module/abstract_methods.rb
244
245
  - lib/eac_ruby_utils/patches/module/acts_as_abstract.rb
245
246
  - lib/eac_ruby_utils/patches/module/acts_as_immutable.rb
247
+ - lib/eac_ruby_utils/patches/module/acts_as_instance_method.rb
246
248
  - lib/eac_ruby_utils/patches/module/common_concern.rb
247
249
  - lib/eac_ruby_utils/patches/module/compare_by.rb
248
250
  - lib/eac_ruby_utils/patches/module/context.rb