statinize 0.4.5 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/statinize/statinizable.rb +9 -5
- 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: 18e7bbf61f4e9326827c4b721729b7dc7951865b7958633623093f10e1dca060
|
4
|
+
data.tar.gz: 0a01cbb40f53d9397b5e4d387c276bc98091dea54b373d6526341fb207671f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcba8fe61c715595a5b2584c90af44fe51671cc36fda434ef9afa7175e2fda0e14c8b22d9e6a51fe01d331cbf8b327db8143389e74f6080bd09ec8bf4fb15f88
|
7
|
+
data.tar.gz: 8d9f9f87ddb691865ce511c273864a5b1de20c78cc04134608e77f39fc28fc7f8695a211aae6b42deb3299391aca7a2dc6b9edeabd905df950f1d8149a96f619
|
@@ -21,8 +21,6 @@ module Statinize
|
|
21
21
|
def initialize(options = {}, *args, &block)
|
22
22
|
symbolized = options.transform_keys(&:to_sym)
|
23
23
|
|
24
|
-
instantiate_defaults
|
25
|
-
|
26
24
|
if private_methods(false).include? :initialize
|
27
25
|
super(options, *args, &block)
|
28
26
|
check_defined!(symbolized)
|
@@ -32,6 +30,8 @@ module Statinize
|
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
33
|
+
instantiate_defaults
|
34
|
+
|
35
35
|
run_before_callbacks
|
36
36
|
|
37
37
|
define_validation
|
@@ -69,12 +69,16 @@ module Statinize
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def instantiate_defaults
|
72
|
-
statinizer.attributes.select
|
72
|
+
undefined_attributes = statinizer.attributes.select do |attribute|
|
73
|
+
public_send(attribute.name).nil?
|
74
|
+
end
|
75
|
+
|
76
|
+
undefined_attributes.select { |a| a.options.key?(:default) }.each do |attribute|
|
73
77
|
public_send("#{attribute.name}=", attribute.default.deep_dup)
|
74
78
|
end
|
75
79
|
|
76
|
-
|
77
|
-
public_send("#{attribute.name}=", attribute.default_exec
|
80
|
+
undefined_attributes.select { |a| a.options.key?(:default_exec) }.each do |attribute|
|
81
|
+
public_send("#{attribute.name}=", instance_exec(&attribute.default_exec))
|
78
82
|
end
|
79
83
|
end
|
80
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statinize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barseek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Statinization gem. Allows for creation of attributes for a class with
|
14
14
|
a given type.
|