no_integrity 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/no_integrity/no_integrity.rb +9 -2
- data/lib/no_integrity/version.rb +1 -1
- data/spec/no_integrity_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1c18d1c25fc02a44437214089be834efda7a80
|
4
|
+
data.tar.gz: 027d99dc8846bc57bcaf57a942a8b7fe52586ce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 420340b9ae8a1c8cf6446b87890fcf70d057c9a3bee5c3468dee41914df5cabbc189eb3a841527442bc26e3aef7cdfef1b6c73095daf7b4a111a0cba5f0c4e6b
|
7
|
+
data.tar.gz: a458d17f2b3df33ce6c88795d9b509deeea83617afc580413d4dd1e058f4cef5d9981bd59fee24ce8e57e07b2ec72e94a9b748f165d7715b3358bc6421b3ca91
|
@@ -80,6 +80,7 @@ module NoIntegrity
|
|
80
80
|
|
81
81
|
def get_no_attribute(attribute_name)
|
82
82
|
initialize_no_attribute_store!
|
83
|
+
|
83
84
|
no_val = self.__no_attr_store[attribute_name.to_sym]
|
84
85
|
|
85
86
|
no_val.nil? ? no_attribute_mappings[attribute_name.to_sym][:default] : no_val
|
@@ -91,11 +92,13 @@ module NoIntegrity
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def initialize_no_attribute_store!
|
94
|
-
return true if @__initialized_attribute_store
|
95
|
+
return true if @__initialized_attribute_store && !dirty_keys?
|
95
96
|
# Initialize an empty hash if we are something else...
|
96
97
|
self.__no_attr_store = { } unless self.__no_attr_store.is_a?(Hash)
|
97
98
|
# Symbolize all of the keys
|
98
|
-
self.__no_attr_store
|
99
|
+
self.__no_attr_store.keys.each do |key|
|
100
|
+
self.__no_attr_store[key.to_sym] = self.__no_attr_store.delete(key) unless key.is_a?(Symbol)
|
101
|
+
end
|
99
102
|
@__initialized_attribute_store = true
|
100
103
|
end
|
101
104
|
|
@@ -117,4 +120,8 @@ module NoIntegrity
|
|
117
120
|
return value
|
118
121
|
end
|
119
122
|
|
123
|
+
def dirty_keys?
|
124
|
+
self.__no_attr_store.is_a?(Hash) && self.__no_attr_store.keys.any? { |k| !k.is_a?(Symbol) }
|
125
|
+
end
|
126
|
+
|
120
127
|
end
|
data/lib/no_integrity/version.rb
CHANGED
data/spec/no_integrity_spec.rb
CHANGED
@@ -27,6 +27,16 @@ describe NoIntegrity do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
context "initialized from a stringified hash" do
|
31
|
+
|
32
|
+
let(:arbs) { MrArbitrary.new({ 'hair' => 'brown' }) }
|
33
|
+
|
34
|
+
it "gets the correct value" do
|
35
|
+
expect(arbs.hair).to eq('brown')
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
30
40
|
it "should know where the attributes are being stored" do
|
31
41
|
expect(arbs.class.no_attr_store).to be_an_instance_of Symbol
|
32
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: no_integrity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Tulskie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|