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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afb314b4a6c9f3ebcd204c252459c4fdfedc58a01b05dc7128fabb77562109eb
4
- data.tar.gz: a2f0a417882c92e43dce65ace85a0e94b3debc9cdcfbcb0fc481a82d0b38f1e6
3
+ metadata.gz: 85aa8a30cca8236b416c02fb2c5517ab3133e6bc9d6a87ecd51dea067712b150
4
+ data.tar.gz: 3ca83deb7cbd4036e99ae00c42890a985374b9185a59ea31b0c1f0df87219339
5
5
  SHA512:
6
- metadata.gz: c7b89e7cc4210c2d0d09ecfd3fffc0182226b3ca699fcadb5a27fd5d32cde12ecad95f471314212813b43f639a4a3181170bc84a03ef7021c120159b4087c4c1
7
- data.tar.gz: 5a6b2c19aff0a6f2ea5b3c793ea5502704d010d2c8292c97e33e393eb1e722a91e6b309114b58fee93a440c9b0e30ff94a10ee898c1eaf282d438ca931c66f45
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.3)
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.1.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 = klass.ancestors.select { |a| a.is_a? Initializer }
43
+ parent_initializers(klass).map(&:args)
44
+ .reduce(args) { |result, parent_args| parent_args.merge result }
45
+ end
41
46
 
42
- parent_initializers.map(&:args)
43
- .reduce(args) { |result, parent_args| parent_args.merge result }
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
- super()
64
+ __original_initialize
60
65
  end
61
66
  CODE
62
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tensai
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tensai-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Fischer