apple_core 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f78954a2f3780ab80a53db0893ef7b7c20047c28d3144d8b12bba76233bde14
4
- data.tar.gz: 62ed470b4b4f54de9319edb1fc16601c144252a215124e19388904d5a3931ab0
3
+ metadata.gz: 757255ae409a091e04dba5776628ae28c89e95b3e33f3aa44734a3dfe1797bba
4
+ data.tar.gz: 2dac16f8a9b9e1e430f8bb2facf9ad900687cfd308f6c9bd53a7480076704056
5
5
  SHA512:
6
- metadata.gz: b8b0db52a2b40174eeb7b6a8a00f7b01b3952a2da6b4a419f19202afa0f11ea961ec810b8dca2b26f4702211c7c25cf229e517a0ac60a3ded1e1d3bbc736986c
7
- data.tar.gz: 8f3a7c790197e7f05acef286df00cae70299e48f064d9c21142c889a793989ed346cf990d5891dc3251d47ed38821f31b24c8b16cd55cc2d1d9fc5877fd8f816
6
+ metadata.gz: 134fe2c31b537e9d297a1c3efdd27c9eb3d15457071006747c35f15cecc15183b78ad1a05c7f20d1f5d57430c4ca2ffe937c9994ee127816cb2bc608444608c7
7
+ data.tar.gz: 6570d7870fbf243e87dc19e8fcb20b8af28d37692ddfba9f77fdd7a7143f1004db8bb9a65a21ab0b0d9eb3ea87e63e5bfd9cc5613695e3a7b229f723374dc9d5
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- ��
2
- �p��'_7�ٕ"~὿����J{Ap��%oL��e>�1�r�� W:q2E6�i�T�"YUX�����N�w��0����~��
1
+ ([��iX��A/�)Ee����K�Z�)vF�Wd
2
+ H����t+a��Z���%�u��u`rk
3
+ �ػ:���o�ok�>lia�G���.-��q+22�)Pb�Ӂےb����h�>s2Q�R$�L��ʐ��y.��K[i%���O�#/R�@�+�p#�ț���
4
+ I�
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppleCore
4
+ module Refinements
5
+ module DeepDup
6
+ refine ::Array do
7
+ unless method_defined?(:deep_dup)
8
+ def deep_dup
9
+ map { |i| i.respond_to?(:deep_dup) ? i.deep_dup : i.dup }
10
+ end
11
+ end
12
+ end
13
+
14
+ refine ::Object do
15
+ unless method_defined?(:deep_dup)
16
+ def deep_dup
17
+ dup
18
+ end
19
+ end
20
+ end
21
+
22
+ refine ::Hash do
23
+ unless method_defined?(:deep_dup)
24
+ def deep_dup
25
+ dup.tap do |hash|
26
+ each_pair do |key, value|
27
+ if key.frozen? && key.is_a?(::String)
28
+ hash[key] = value.deep_dup
29
+ else
30
+ hash.delete(key)
31
+ hash[key.deep_dup] = value.deep_dup
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ module ActiveSupport
43
+ class HashWithIndifferentAccess < Hash
44
+ using ::AppleCore::Refinements::DeepDup
45
+
46
+ unless method_defined?(:deep_dup)
47
+ def deep_dup
48
+ dup.tap do |hash|
49
+ each_pair do |key, value|
50
+ if key.frozen? && key.is_a?(::String)
51
+ hash[key] = value.deep_dup
52
+ else
53
+ hash.delete(key)
54
+ hash[key.deep_dup] = value.deep_dup
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -20,6 +20,28 @@ refine ::Hash do
20
20
  Transforms::Hash.deep_underscore_keys(self)
21
21
  end
22
22
 
23
+ unless method_defined?(:slice)
24
+ def slice(*keys)
25
+ keys.each_with_object({}) do |k, hash|
26
+ hash[k] = self[k] if has_key?(k)
27
+ end
28
+ end
29
+ end
30
+
31
+ unless method_defined?(:slice!)
32
+ def slice!(*keys)
33
+ omit = slice(*self.keys - keys)
34
+
35
+ hash = slice(*keys)
36
+ hash.default = default
37
+ hash.default_proc = default_proc if default_proc
38
+
39
+ replace(hash)
40
+
41
+ omit
42
+ end
43
+ end
44
+
23
45
  def symbolize_keys
24
46
  result = {}
25
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppleCore
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thegranddesign
@@ -31,7 +31,7 @@ cert_chain:
31
31
  Y2GAoHKstmfIVhc4XHOPpmTd2o/C29O9oaRgjrkfQEhF/KvJ/PhoV5hvokzsCyI5
32
32
  iUeXPfvrGD/itYIBCgk+fnzyQQ4QtE5hTQaWQ3o2
33
33
  -----END CERTIFICATE-----
34
- date: 2018-04-30 00:00:00.000000000 Z
34
+ date: 2018-05-03 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activemodel
@@ -116,6 +116,7 @@ files:
116
116
  - lib/apple_core/active_model/validations/inclusion_validator.rb
117
117
  - lib/apple_core/active_record/base.rb
118
118
  - lib/apple_core/refinements/array.rb
119
+ - lib/apple_core/refinements/deep_dup.rb
119
120
  - lib/apple_core/refinements/hash.rb
120
121
  - lib/apple_core/refinements/integer.rb
121
122
  - lib/apple_core/refinements/string.rb
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- �WL@��]����H�<2˨�l$�3x��aR-NJ�1%5t��RR �t{`d�-v|��J7G|x��R��0i+ץ4Uʾ.y�@�Š 5��2j�u��waƨ�tca|�x�����;--.�'o��^��d����>)�WD��Ú����%�*c�u���;���0]��G��1P��t��5“�Zbi�A��`�X�7�04�K*�з�[�X[l�=/@��0�_�}��K3�v�S2��LA�\�� !
1
+ R��,��ɢH�;�]R��JO�� ���11™��[�Oл�����bߞ�J���u��Ki����j�!&otY�|DR.