tensai-core 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tensai/util/initializer.rb +7 -11
- 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: 04643da856a7b297e49002dd57e6a3b5919a29a89017ed6fbe52a909157a791a
|
4
|
+
data.tar.gz: 948e34102d279465bcac2d05736069a958bdf24aad67885b0876bda719297a42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6afeec5b33779f3eedc51c26617872c0ea80ac50274cc2f9f4516f80011836de9dd4ddf21caedba13df820226d66a05c6d24c9763f3e9d5e04358314c0990eee
|
7
|
+
data.tar.gz: 2cf1b9730e37548c6c05dcb4c69f483c81d2192887a6b4f4f16546d05d961096021c4fac455acfbfe67a048e816af9604c6cc3793e35108eb5145d8078c6b622
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ require 'tensai/types'
|
|
5
5
|
module Tensai::Util
|
6
6
|
# @private
|
7
7
|
#
|
8
|
-
#
|
8
|
+
# Include in classes to insert boilerplate constructor, dry-types typecheck and getters
|
9
9
|
#
|
10
10
|
class Initializer < Module
|
11
11
|
attr_reader :args
|
@@ -17,7 +17,6 @@ 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
|
21
20
|
|
22
21
|
klass.instance_eval do
|
23
22
|
define_method :__check_argument_type do |argument, value|
|
@@ -29,9 +28,9 @@ module Tensai::Util
|
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
|
-
|
31
|
+
define_method :after_initialize, -> {}
|
33
32
|
|
34
|
-
|
33
|
+
attr_reader(*this_class_args.keys)
|
35
34
|
end
|
36
35
|
|
37
36
|
klass.class_eval InitializeMethod.new(all_args).code, __FILE__, __LINE__ + 11
|
@@ -40,12 +39,9 @@ module Tensai::Util
|
|
40
39
|
private
|
41
40
|
|
42
41
|
def all_args_for(klass)
|
43
|
-
parent_initializers
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
def parent_initializers(klass)
|
48
|
-
klass.ancestors.select { |a| a.is_a? Initializer }
|
42
|
+
parent_initializers = klass.ancestors.select { |a| a.is_a? Initializer }
|
43
|
+
parent_initializers.map(&:args)
|
44
|
+
.reduce(args) { |result, parent_args| parent_args.merge result }
|
49
45
|
end
|
50
46
|
|
51
47
|
#
|
@@ -61,7 +57,7 @@ module Tensai::Util
|
|
61
57
|
def initialize(#{signature})
|
62
58
|
#{assign_instance_variables_code}
|
63
59
|
#{check_argument_types_code}
|
64
|
-
|
60
|
+
after_initialize
|
65
61
|
end
|
66
62
|
CODE
|
67
63
|
end
|
data/lib/tensai/version.rb
CHANGED