inherited_class_var 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 7e265f14ae462bf2896bb319cd5652912b583e13
4
- data.tar.gz: cf4cc16e671cb1de045ebb1033677cb798fade78
3
+ metadata.gz: 5c5ef71f52f5e727e244a172a79678277c22d97f
4
+ data.tar.gz: 28ee4455746c407372eefa3017e5d3c8686250d6
5
5
  SHA512:
6
- metadata.gz: 5cd98dfc7200e8f5b4a1c911dcbe0ccb78568d0477d744d03762b6e2d52ae3765f0800fa50a56572fa5572e9476332a28076e6c0e4272c4095139a1addc9e15b
7
- data.tar.gz: 965c29758a5896359733275d8faf86c9cfb30d8f8108e9b275fef11351af0c56f19d6b457bbde88d1b32f811c68cca5903900b4db2a5efd98af41134eca9070e
6
+ metadata.gz: 312e9432006f123571e33cf44260c6e345d0d7585adec3d0b6bcf1eec6c0334d5228efe1973d805a05dede3c41ec214182271127bc9d35cb72049044179c7357
7
+ data.tar.gz: d0c85a0549b2f4d5df589bdcb49754ab857483333fe681e9f7d44d050132d9313fece11bee61fa751c58e94ddffdba135b8299d3cdb47cbde36d792ec060f92b
@@ -1,3 +1,3 @@
1
1
  module InheritedClassVar
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -21,13 +21,16 @@ module InheritedClassVar
21
21
  hidden_variable_name = hidden_variable_name(variable_name)
22
22
 
23
23
  define_singleton_method variable_name do
24
- inherited_class_var(hidden_variable_name, {}, :merge)
24
+ inherited_class_var(hidden_variable_name, {}, :deep_merge)
25
+ end
26
+
27
+ define_singleton_method :"raw_#{variable_name}" do
28
+ class_var(hidden_variable_name, {})
25
29
  end
26
30
 
27
31
  define_singleton_method :"merge_#{variable_name}" do |merge_value|
28
- value = instance_variable_get(hidden_variable_name) || instance_variable_set(hidden_variable_name, {})
29
32
  deep_clear_class_cache(hidden_variable_name)
30
- value.merge!(merge_value)
33
+ public_send(:"raw_#{variable_name}").deep_merge!(merge_value)
31
34
  end
32
35
  end
33
36
 
@@ -64,6 +67,13 @@ module InheritedClassVar
64
67
  :"@_#{variable_name}"
65
68
  end
66
69
 
70
+ # @param variable_name [Symbol] class variable name
71
+ # @param default_value [Object] default value of the class variable
72
+ # @return [Object] a class variable of the specific class without taking into account inheritance
73
+ def class_var(variable_name, default_value)
74
+ instance_variable_get(variable_name) || instance_variable_set(variable_name, default_value)
75
+ end
76
+
67
77
  # @param variable_name [Symbol] class variable name (recommend :@_variable_name)
68
78
  # @param default_value [Object] default value of the class variable
69
79
  # @param merge_method [Symbol] method to merge values of the class variable
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inherited_class_var
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Chung
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-05-31 00:00:00.000000000 Z
12
+ date: 2016-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport