eac_ruby_utils 0.117.1 → 0.118.1

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: 8b2abb2644a8097a4b79570405e19020ac83d943fca57f043b622379e49f2ba0
4
- data.tar.gz: c35af3b5fae5730b43dbe82d52cb88bd68d37f635470e49affbddcf955d6d202
3
+ metadata.gz: 904ea7b7f6c0df2889d854f1f2aba29f52511bab46ab634cc6faf850fe2421f4
4
+ data.tar.gz: 878c847fcdc7214bafc113c5a3af0269537c967858c6d399381f54ae997f0681
5
5
  SHA512:
6
- metadata.gz: 74ac551580b13b23afa5f958103da31b151f5f8a127096d07e1d95a2c89b68fe22ae713438b209dbcbe6b08ef6f3b1622d5573d7a134ca54be31633db9419d06
7
- data.tar.gz: 8c3a337259facb4bedfed729fb6360478839dc58ac6b59776ad135b9d899fc664369e73e06d721976525d040a0b5cb4d34b2fc16eb7d8c3df6778b3d63fb32bc
6
+ metadata.gz: d7c3d1433a92489eb25ba845e0bc84b34a8065ececa9f27220a591176d4197a3ecf66de8f69dd27970fed3e3e5b24d9ae50679dcea3b19e0a104ef82d634e455
7
+ data.tar.gz: 5ba94d00fe8576164dcc74caa66e54f13fdc5abf1bf9c9d8d7704a3727837a0dde5dac3c0e1ffa7fcf4ee37180faa41475e9a888dd235ec1fb23fdbdce9bf414
@@ -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
@@ -29,7 +29,6 @@ module EacRubyUtils
29
29
  # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
30
30
  def all_gems
31
31
  ::Gem::Specification.map { |gemspec| ::EacRubyUtils::GemsRegistry::Gem.new(self, gemspec) }
32
- .sort
33
32
  end
34
33
  end
35
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.1'
4
+ VERSION = '0.118.1'
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.117.1
4
+ version: 0.118.1
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-23 00:00:00.000000000 Z
11
+ date: 2023-06-24 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