var_block 1.0.5 → 1.0.6

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: e4402003ba6ed9894c5c346f3dac996e8b0a52c1
4
- data.tar.gz: e1f48bd2618296ba9392180cbd0cdd6b6d6c4568
3
+ metadata.gz: b5eff5e3d3eabecc4648ffda2370f50e17b2d4ab
4
+ data.tar.gz: 9843dd46c637d96897b68f99bec939cbc2d8015c
5
5
  SHA512:
6
- metadata.gz: f23bea2ab3859970eaa3669d961a75634a4f569fe22eace63c785f76037a41add32d381b0a8644f45518fe970182a1720798f0d1a837dbb06ae16db598da1dcb
7
- data.tar.gz: 7dacd9c7c46940e469e55e0fdff1d602cffc3a449f43847d18462a90df1f5461019d45589795183e37591d6bf8217e380f16186aef5bb0038f5c537f042386fa
6
+ metadata.gz: 7dd22cc5fe605b40680407df3cd704f637d7a8774c54bcbb5ee15578ea365220d7126b4236618f5211c7e2065d9521debf85112edd5c2e4a883c8db2efbdb6c2
7
+ data.tar.gz: f65d3d1e7eb077ef7d0f6a8e8a71e846c6ae5feffa201ed1abd52d8c587262bdca278c087c0617b1d3e05273bd6230101b72fc39ccc1e365d25d5fee3a5b0c4d
@@ -32,7 +32,7 @@ module VarBlock
32
32
  end
33
33
 
34
34
  def with(var_hash_parent = nil, **variables)
35
- var_hash = VarHash.new(var_hash: var_hash_parent)
35
+ var_hash = VarHash.new_from_var_hash(var_hash: var_hash_parent)
36
36
 
37
37
  variables.each do |key, value|
38
38
  var_hash[key] = value
@@ -6,18 +6,20 @@ module VarBlock
6
6
  include VarBlock::Globals
7
7
  include VarBlock::Support
8
8
 
9
- def initialize(var_hash: nil)
9
+ def self.new_from_var_hash(var_hash: nil)
10
+ new_var_hash = VarHash.new
10
11
  if var_hash
11
12
  raise ArgumentError.new('`instance` should be a `VarHash` object') unless var_hash.is_a? VarHash
12
- self.merge!(var_hash)
13
+ new_var_hash = new_var_hash.merge!(var_hash.to_h)
13
14
  end
14
- self
15
+ new_var_hash
15
16
  end
16
17
 
17
18
  def with(variables = {})
18
19
  super(self, variables)
19
20
  end
20
21
 
22
+ # OVERRIDES Hash `merge`
21
23
  def merge(variables)
22
24
  raise ArgumentError, '`merge` does not accept a block. Are you looking for `merged_with` instead?' if block_given?
23
25
 
@@ -27,9 +29,9 @@ module VarBlock
27
29
  # if variable already has a value, we need to wrap both values into a VarArray if not yet a VarArray
28
30
  if self.has_key?(key)
29
31
  unless current_value.is_a? VarArray
30
- self[key] = VarArray.new(array_wrap(current_value) + array_wrap(value)) unless current_value.is_a? VarArray
32
+ self[key] = VarArray.new(array_wrap(current_value) + array_wrap(value))
31
33
  else
32
- self[key].concat(array_wrap(value))
34
+ self[key] = self[key].clone.concat(array_wrap(value))
33
35
  end
34
36
 
35
37
  # else if new variable
@@ -1,3 +1,3 @@
1
1
  module VarBlock
2
- VERSION = '1.0.5'.freeze
2
+ VERSION = '1.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: var_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jules Roman B. Polidario