modeling 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1808a9621f5f4e419a137e8f2cc01c85aebcc29e94f20c270301e1d2dafd6806
4
- data.tar.gz: 0d24e7745e3c3e177060bd436856b63adc59c89ca09ff7b01e184fc804cc622c
3
+ metadata.gz: e3cc5b79ca0d36340e35381ab51d1b4d09486812bb8479267128a557e0130c01
4
+ data.tar.gz: b8ff810f7317108cbf1b8ef7290355041a8d29d20ecb3a57ad47f66fd3edc2f2
5
5
  SHA512:
6
- metadata.gz: 7728919bd5af78a82bed604551715f2bb4d10c4cf736d232b8d73293e7db99a34ef233dc5308121993073c7b7ca8b9e4287a278ae5e9a798a1bbf2fd8b7281b7
7
- data.tar.gz: 76d4cc5dd6006574ad4c225a695c36a6e6886d8ae9a40aa26159e873ce572992db6ff4e45f54b8b463298eaa2195d0d5fbf039a64f30c3bde8156f8bb44ce729
6
+ metadata.gz: 6044d7ac29c9b23834aa7a848dc10c11430be05262bcaab38ad5417ee7a605d515a1d66bce01f6ff639750e566826856e39ed4aa46a33ffb26f36b71011970bb
7
+ data.tar.gz: 3a94d368fc0e022e2aaffccfb10247cfab48a7df9da53150a7a618b21cac7c529dbe906cd8c36169831dd499a9db93e586947147528ec4d17aba67260eb15341
@@ -41,11 +41,21 @@ module Modeling
41
41
  define_method :initialize do |*a, **na, &b|
42
42
  model_fields = initializer_class.model_fields
43
43
  model_arguments = Modeling.model_arguments model_fields, *a, **na
44
- super(*(a[model_arguments.size..] || []), **na.except(*model_arguments.keys), &b)
44
+ super_call = proc do |*asc, **nasc, &bsc|
45
+ if asc.empty? && nasc.empty? && !bsc
46
+ super(*(a[model_arguments.size..] || []), **na.except(*model_arguments.keys), &b)
47
+ else
48
+ super(*asc, **nasc, &bsc)
49
+ end
50
+ end
45
51
  model_fields.each do |f|
46
52
  instance_variable_set f.attribute_name, model_arguments[f.name] if f.create_attr?
47
53
  end
48
- instance_exec **model_arguments, &initializer if initializer
54
+ if initializer
55
+ instance_exec super_call, **model_arguments, &initializer
56
+ else
57
+ super_call.call
58
+ end
49
59
  end
50
60
  end
51
61
 
@@ -1,3 +1,3 @@
1
1
  module Modeling
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modeling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Łukasz Pomietło
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-18 00:00:00.000000000 Z
11
+ date: 2024-04-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " Enables writting class initializers and attribute accessors in one
14
14
  line. \n Struct class alternative. Keyword & positional arguments mixing. Optional