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 +4 -4
- data/lib/modeling/module.rb +12 -2
- data/lib/modeling/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3cc5b79ca0d36340e35381ab51d1b4d09486812bb8479267128a557e0130c01
|
4
|
+
data.tar.gz: b8ff810f7317108cbf1b8ef7290355041a8d29d20ecb3a57ad47f66fd3edc2f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6044d7ac29c9b23834aa7a848dc10c11430be05262bcaab38ad5417ee7a605d515a1d66bce01f6ff639750e566826856e39ed4aa46a33ffb26f36b71011970bb
|
7
|
+
data.tar.gz: 3a94d368fc0e022e2aaffccfb10247cfab48a7df9da53150a7a618b21cac7c529dbe906cd8c36169831dd499a9db93e586947147528ec4d17aba67260eb15341
|
data/lib/modeling/module.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
|
data/lib/modeling/version.rb
CHANGED
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
|
+
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-
|
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
|