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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85aa8a30cca8236b416c02fb2c5517ab3133e6bc9d6a87ecd51dea067712b150
4
- data.tar.gz: 3ca83deb7cbd4036e99ae00c42890a985374b9185a59ea31b0c1f0df87219339
3
+ metadata.gz: 04643da856a7b297e49002dd57e6a3b5919a29a89017ed6fbe52a909157a791a
4
+ data.tar.gz: 948e34102d279465bcac2d05736069a958bdf24aad67885b0876bda719297a42
5
5
  SHA512:
6
- metadata.gz: 576c80dbfafa43564d472933112474ea0a058ac73e66cacdbb21d513045689fb88cd1fccfb58e7af58e51f40054d1ea811dded80a41954869623d506b9f4e757
7
- data.tar.gz: 46baf488e9b612046c876ce83e762e7cc47bacabd6407dc5f6df61ce073183705fa83e13fa3c1c670cf6ac7fed25dc16dbbdd0345e23e6413aeba83aea32b349
6
+ metadata.gz: 6afeec5b33779f3eedc51c26617872c0ea80ac50274cc2f9f4516f80011836de9dd4ddf21caedba13df820226d66a05c6d24c9763f3e9d5e04358314c0990eee
7
+ data.tar.gz: 2cf1b9730e37548c6c05dcb4c69f483c81d2192887a6b4f4f16546d05d961096021c4fac455acfbfe67a048e816af9604c6cc3793e35108eb5145d8078c6b622
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tensai-core (0.1.6)
4
+ tensai-core (0.1.7)
5
5
  dry-types (~> 1.1)
6
6
 
7
7
  GEM
@@ -5,7 +5,7 @@ require 'tensai/types'
5
5
  module Tensai::Util
6
6
  # @private
7
7
  #
8
- # Prepend to classes to insert boilerplate constructor, dry-types typecheck and getters
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
- attr_reader(*this_class_args.keys)
31
+ define_method :after_initialize, -> {}
33
32
 
34
- alias_method :__original_initialize, :initialize unless has_parent_initializers
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(klass).map(&:args)
44
- .reduce(args) { |result, parent_args| parent_args.merge result }
45
- end
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
- __original_initialize
60
+ after_initialize
65
61
  end
66
62
  CODE
67
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tensai
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
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.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Fischer