no_integrity 0.5.2 → 0.6.0

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: 53786fc88468d31ecc8aa8cc51efbd5440bc8504
4
- data.tar.gz: 10238f3f6672aee810706ef7d97c64cac2ffb958
3
+ metadata.gz: 8a1c18d1c25fc02a44437214089be834efda7a80
4
+ data.tar.gz: 027d99dc8846bc57bcaf57a942a8b7fe52586ce9
5
5
  SHA512:
6
- metadata.gz: cb9e59afe534b101dcd8649470881516387354f75275b516860a9c178b73b26f33a63465fbea4c3a16b9811127205b1c633b97ffbe8b29f1076af01528d1ffcd
7
- data.tar.gz: 90ffc6c02e04e6db40823fb9ec8d3d18d2f80188d124726aba331bc68b60aa747f8ec00503dc60d31bcd3038513130eb7b82db29de22fcd5eada8576b99fa9a8
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 = Hash[self.__no_attr_store.map { |k, v| [k.to_sym, v] }]
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
@@ -1,3 +1,3 @@
1
1
  module NoIntegrity
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -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.5.2
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-02-04 00:00:00.000000000 Z
11
+ date: 2016-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec