attribute_struct 0.2.12 → 0.2.14

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: 4678195877f88a043df9e50bb70bd2b15d6e0de6
4
- data.tar.gz: 67a4f4870ed31aeabb2e43602c8d996bc2f550ee
3
+ metadata.gz: 2784bc7275103df06114555bef8c340a6af7e41d
4
+ data.tar.gz: a718c494924468d7653683451f5734debeeaf536
5
5
  SHA512:
6
- metadata.gz: 5d0d0c9f6dd9fb55e757fb2a91988cf7d58ded85d393e75f03261d27f4df0fe9692b1d64385e6cc186079a8e3a7cbb4be494101bd4b6cbf03689d4be17aace36
7
- data.tar.gz: 27a40c5108a547180fcbb91f2f78db07adf405e42b6ed9a3a3b12a3c533ff594ba52d92f10d84f6d1b689e05586b7cd4d4fe70a545864de136dbdae54125fb91
6
+ metadata.gz: ebdb20db6a9a5a1060a7868f60aeb9f1ed1a2e8e00767027ce530d5b2a7584d7398e16b69c4822c87b0d2325c21db9425bd5094b305e319d04205111998dcd22
7
+ data.tar.gz: a5e0a40f61d168e0653f9322123f0b33ece9e0b576db793bb0910643cd3fc37ffe201d8a6178ac45d12e3bfc1f5bea8fb4c43ea6ee5b9124e33651bef218ac47
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## v0.2.14
2
+ * Fix `:value_collapse` option to prevent multiple nestings
3
+
1
4
  ## v0.2.12
2
5
  * Implementation updates to monkey camels helper
3
6
  * Provide bang style helper methods for all helpers
@@ -225,7 +225,7 @@ class AttributeStruct
225
225
  if value.class == Hash
226
226
  Mash.from_hash(value)
227
227
  elsif value.is_a?(Array)
228
- value.collect { |e| convert_value(e) }
228
+ value.class.new.replace(value.collect { |e| convert_value(e) })
229
229
  else
230
230
  value
231
231
  end
@@ -172,7 +172,9 @@ class AttributeStruct < BasicObject
172
172
  if(orig == :__unset__)
173
173
  @table[sym] = base
174
174
  else
175
- orig = [orig] unless orig.is_a?(::Array)
175
+ unless(orig.is_a?(CollapseArray))
176
+ orig = CollapseArray.new.push(orig)
177
+ end
176
178
  orig << base
177
179
  @table[sym] = orig
178
180
  end
@@ -193,14 +195,16 @@ class AttributeStruct < BasicObject
193
195
  end
194
196
  block.arity == 0 ? leaf._build(&block) : leaf._build(leaf, &block)
195
197
  if(orig)
196
- orig = [orig] unless orig.is_a?(::Array)
198
+ unless(orig.is_a?(CollapseArray))
199
+ orig = CollapseArray.new.push(orig)
200
+ end
197
201
  orig << leaf
198
202
  else
199
203
  orig = leaf
200
204
  end
201
- @table[sym] = result
205
+ @table[sym] = orig
202
206
  else
203
- if(args.size > 1 && args.all?{|i| i.is_a?(::String) || i.is_a?(::Symbol)})
207
+ if(args.size > 1 && args.all?{|i| i.is_a?(::String) || i.is_a?(::Symbol)} && !_state(:value_collapse))
204
208
  @table[sym] = _klass_new unless @table[sym].is_a?(_klass)
205
209
  endpoint = args.inject(@table[sym]) do |memo, k|
206
210
  unless(memo[k].is_a?(_klass))
@@ -211,7 +215,9 @@ class AttributeStruct < BasicObject
211
215
  return endpoint # custom break out
212
216
  else
213
217
  if(_state(:value_collapse) && !(leaf = @table[sym]).nil?)
214
- leaf = CollapseArray.new.push(leaf) unless leaf.is_a?(CollapseArray)
218
+ unless(leaf.is_a?(CollapseArray))
219
+ leaf = CollapseArray.new.push(leaf)
220
+ end
215
221
  leaf << (args.size > 1 ? args : args.first)
216
222
  @table[sym] = leaf
217
223
  else
@@ -2,5 +2,5 @@ require 'attribute_struct/attribute_struct'
2
2
 
3
3
  class AttributeStruct
4
4
  # Current library version
5
- VERSION = ::Gem::Version.new('0.2.12')
5
+ VERSION = ::Gem::Version.new('0.2.14')
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-02 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Attribute structures
14
14
  email: chrisroberts.code@gmail.com