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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd5a1c15473a68cad29248c698c58fb190a37e432bfeb41d8622594904e79060
4
- data.tar.gz: 7120d733e7389966c5378b924beb2a638eb2bfc283437020cd5bdf8601608fd5
3
+ metadata.gz: 18e7bbf61f4e9326827c4b721729b7dc7951865b7958633623093f10e1dca060
4
+ data.tar.gz: 0a01cbb40f53d9397b5e4d387c276bc98091dea54b373d6526341fb207671f8e
5
5
  SHA512:
6
- metadata.gz: c67c423f48b274dd35b0ca582ea90e7081fb732ecf1252e97e5242ba2dfbbfc2434c93484eb2752d291ab19eeaaaf28b878925e2bd30a082709d2b64449932a5
7
- data.tar.gz: af01616f0a9a41c3799c3384285ea741dee5301f88beb5d2b6afc5c762f0219b85d16c5eb5c2a6d0994bd72034db0d0e74ebf8548cec68df08f0fd796b66fad2
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 { |a| a.options.key?(:default) }.each do |attribute|
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
- statinizer.attributes.select { |a| a.options.key?(:default_exec) }.each do |attribute|
77
- public_send("#{attribute.name}=", attribute.default_exec.call)
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.5
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-24 00:00:00.000000000 Z
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.