tensai-core 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/tensai/util/initializer.rb +9 -4
- data/lib/tensai/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85aa8a30cca8236b416c02fb2c5517ab3133e6bc9d6a87ecd51dea067712b150
|
4
|
+
data.tar.gz: 3ca83deb7cbd4036e99ae00c42890a985374b9185a59ea31b0c1f0df87219339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 576c80dbfafa43564d472933112474ea0a058ac73e66cacdbb21d513045689fb88cd1fccfb58e7af58e51f40054d1ea811dded80a41954869623d506b9f4e757
|
7
|
+
data.tar.gz: 46baf488e9b612046c876ce83e762e7cc47bacabd6407dc5f6df61ce073183705fa83e13fa3c1c670cf6ac7fed25dc16dbbdd0345e23e6413aeba83aea32b349
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tensai-core (0.1.
|
4
|
+
tensai-core (0.1.6)
|
5
5
|
dry-types (~> 1.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
27
|
dry-core (~> 0.2)
|
28
28
|
dry-equalizer (~> 0.2)
|
29
|
-
dry-types (1.
|
29
|
+
dry-types (1.2.0)
|
30
30
|
concurrent-ruby (~> 1.0)
|
31
31
|
dry-container (~> 0.3)
|
32
32
|
dry-core (~> 0.4, >= 0.4.4)
|
@@ -17,6 +17,7 @@ module Tensai::Util
|
|
17
17
|
def included(klass) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
18
18
|
this_class_args = args
|
19
19
|
all_args = all_args_for(klass)
|
20
|
+
has_parent_initializers = parent_initializers(klass).length > 1
|
20
21
|
|
21
22
|
klass.instance_eval do
|
22
23
|
define_method :__check_argument_type do |argument, value|
|
@@ -29,6 +30,8 @@ module Tensai::Util
|
|
29
30
|
end
|
30
31
|
|
31
32
|
attr_reader(*this_class_args.keys)
|
33
|
+
|
34
|
+
alias_method :__original_initialize, :initialize unless has_parent_initializers
|
32
35
|
end
|
33
36
|
|
34
37
|
klass.class_eval InitializeMethod.new(all_args).code, __FILE__, __LINE__ + 11
|
@@ -37,10 +40,12 @@ module Tensai::Util
|
|
37
40
|
private
|
38
41
|
|
39
42
|
def all_args_for(klass)
|
40
|
-
parent_initializers
|
43
|
+
parent_initializers(klass).map(&:args)
|
44
|
+
.reduce(args) { |result, parent_args| parent_args.merge result }
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
|
47
|
+
def parent_initializers(klass)
|
48
|
+
klass.ancestors.select { |a| a.is_a? Initializer }
|
44
49
|
end
|
45
50
|
|
46
51
|
#
|
@@ -56,7 +61,7 @@ module Tensai::Util
|
|
56
61
|
def initialize(#{signature})
|
57
62
|
#{assign_instance_variables_code}
|
58
63
|
#{check_argument_types_code}
|
59
|
-
|
64
|
+
__original_initialize
|
60
65
|
end
|
61
66
|
CODE
|
62
67
|
end
|
data/lib/tensai/version.rb
CHANGED