tainbox 0.2.6 → 0.2.8

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
  SHA1:
3
- metadata.gz: 5c16f48e5255c848de788554b4319f35303f855f
4
- data.tar.gz: c29904b5869f58c0fee2c51e89e33d9f11f21391
3
+ metadata.gz: 3fc20a0ada50ebd418d6bb4d319059f5689d267f
4
+ data.tar.gz: 1c35da834f88c56c09fc984f1fda8a1b2c624e0c
5
5
  SHA512:
6
- metadata.gz: 200a19cc05d3e22cb398e3bafd45f57d8eb46d9c6d7ee1b95f7225204de0bc337e43a212d0c92db9e8484967b76abddfcdca13f1ad486373056cdca3a14a4b4f
7
- data.tar.gz: e0be226d72ef0cf58a930e232db7047583d435d4bd5f2c5906625be57cf2dd995e87b10f3f7f9baa840f0306654a6fc1d8380501ef7e6db10ac0e65a0ae77f8b
6
+ metadata.gz: dd4cca5f880887aa74572ecf8e1ed79d1681b8d5eea364dd481b1b3613e23ef3d04cdef5db1c473a173774660681f571a35969671a3674ec9671ce05d39e4aec
7
+ data.tar.gz: 7d1db5b7e11fc1ff950d5ba1eb536ac758fc88c12413b3981c2daa711c6a8f1857b17823934451bd5658ed55dd790872b347e043ce082f9fff365b4a2b34d4d2
data/CHANGELOG.md CHANGED
@@ -11,3 +11,12 @@
11
11
  ## 0.2.6
12
12
 
13
13
  * raise `ArgumentError` if trying to assign a non-hash to `#attributes`
14
+
15
+ ## 0.2.7
16
+
17
+ * Attribute is always set to nil and marked as not provided when the hash assigned via
18
+ `#attributes=` or `#new` does not have that attribute and the attribute does not have a default
19
+
20
+ ## 0.2.8
21
+
22
+ * Prepend internal variables with 'tainbox\_' to avoid clashes with client code
@@ -19,7 +19,7 @@ class Tainbox::AttributeDefiner
19
19
 
20
20
  klass.tainbox_layer.instance_eval do
21
21
  define_method(attribute) do
22
- value = instance_variable_get(:"@#{attribute}")
22
+ value = instance_variable_get(:"@tainbox_#{attribute}")
23
23
  value.is_a?(Tainbox::DeferredValue) ? instance_exec(&value.proc) : value
24
24
  end
25
25
  end
@@ -37,7 +37,7 @@ class Tainbox::AttributeDefiner
37
37
  define_method("#{attribute}=") do |value|
38
38
  tainbox_register_attribute_provided(attribute)
39
39
  value = Tainbox::TypeConverter.new(type, value, options: args).convert if type
40
- instance_variable_set(:"@#{attribute}", value)
40
+ instance_variable_set(:"@tainbox_#{attribute}", value)
41
41
  end
42
42
 
43
43
  define_method("tainbox_set_default_#{attribute}") do
@@ -45,7 +45,11 @@ class Tainbox::AttributeDefiner
45
45
  tainbox_register_attribute_provided(attribute)
46
46
  value = args[:default].deep_dup
47
47
  value = Tainbox::DeferredValue.new(value) if value.is_a?(Proc)
48
- instance_variable_set(:"@#{attribute}", value)
48
+ instance_variable_set(:"@tainbox_#{attribute}", value)
49
+
50
+ else
51
+ tainbox_unregister_attribute_provided(attribute)
52
+ instance_variable_set(:"@tainbox_#{attribute}", nil)
49
53
  end
50
54
  end
51
55
  end
@@ -32,4 +32,8 @@ class Object
32
32
  tainbox_provided_attributes << attribute
33
33
  tainbox_provided_attributes.uniq!
34
34
  end
35
+
36
+ def tainbox_unregister_attribute_provided(attribute)
37
+ tainbox_provided_attributes.delete(attribute)
38
+ end
35
39
  end
@@ -1,3 +1,3 @@
1
1
  module Tainbox
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tainbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Gubitskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport