hashme 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/hashme/properties.rb +6 -1
- data/lib/hashme/version.rb +1 -1
- data/spec/hashme/properties_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2c83753729924cb8ce0b33b18cae286f361d976
|
4
|
+
data.tar.gz: a9e0c44b939e0dca840d64fa1cdd91ad2850e517
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3648a068f2c367ef54172a04e49f3991bd042d087b1288bb99becf3fe2daa87f9f933f0bf1aa9d2a149fa3b8576ca2ab7727144590834dbeaad0743599f47f78
|
7
|
+
data.tar.gz: 8b05b8582dc6ebb5c4167901906eaa0abbbeb5021dbec4ca48fbaa1fb8a81b3852aa24e008c7102e715acefcbb24bf9d25b96479407f469a9e9b6aa0d30f2b79
|
data/README.md
CHANGED
@@ -118,6 +118,10 @@ u.errors.first # [:email, "can't be blank"]
|
|
118
118
|
|
119
119
|
## History
|
120
120
|
|
121
|
+
### 0.2.5 - 2016-06-03 - Again!
|
122
|
+
|
123
|
+
* Adding support for deleting attributes by setting them to nil to keep output clean.
|
124
|
+
|
121
125
|
### 0.2.4 - 2016-06-03
|
122
126
|
|
123
127
|
* Removing `casted_by` property, due to lack of use case and complication it causes.
|
data/lib/hashme/properties.rb
CHANGED
@@ -14,7 +14,12 @@ module Hashme
|
|
14
14
|
def set_attribute(name, value)
|
15
15
|
property = get_property(name)
|
16
16
|
if property
|
17
|
-
|
17
|
+
value = property.build(self, value)
|
18
|
+
if value.nil?
|
19
|
+
delete(property.name)
|
20
|
+
else
|
21
|
+
self[property.name] = value
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
data/lib/hashme/version.rb
CHANGED
@@ -43,6 +43,14 @@ describe Hashme::Properties do
|
|
43
43
|
obj.set_attribute(:name, name)
|
44
44
|
expect(obj[:name]).to eql(name)
|
45
45
|
end
|
46
|
+
|
47
|
+
it "should delete attribute set to nil" do
|
48
|
+
obj.name = "test"
|
49
|
+
expect(obj.name).to eql("test")
|
50
|
+
obj.name = nil
|
51
|
+
expect(obj.name).to be_nil
|
52
|
+
expect(obj.keys.map(&:to_s)).to_not include('name')
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
56
|
describe "#attribtues=" do
|