statinize 0.4.6 → 0.4.7

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: 532ce092aa6b70f135589b09d8c8f7574105e7ecbc17036e3fd2d50ffaf47813
4
- data.tar.gz: deb8189b91a4703070b769968d1858ff77a261afa9565a7695e957bdbf381a86
3
+ metadata.gz: 18e7bbf61f4e9326827c4b721729b7dc7951865b7958633623093f10e1dca060
4
+ data.tar.gz: 0a01cbb40f53d9397b5e4d387c276bc98091dea54b373d6526341fb207671f8e
5
5
  SHA512:
6
- metadata.gz: 83956b014f99a2a5438bbf0304d0bc094cd0ed83329269d1d7d46fa6ca5dd46abf2b19948e980216e1e5bb1a906a9670b26bcd966d2c327f5bd567f59e5f1340
7
- data.tar.gz: 49bc1829a8955fccc561277a5568f7cad00fa129e6c20e8956d2037dbbea29600052eff2da1f0b8f5af720e87a9548f621cbd9488da855a3b53b8f79b652a96d
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,11 +69,15 @@ 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|
80
+ undefined_attributes.select { |a| a.options.key?(:default_exec) }.each do |attribute|
77
81
  public_send("#{attribute.name}=", instance_exec(&attribute.default_exec))
78
82
  end
79
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statinize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barseek