inherited_class_var 0.2.1 → 0.2.2

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: 5c5ef71f52f5e727e244a172a79678277c22d97f
4
- data.tar.gz: 28ee4455746c407372eefa3017e5d3c8686250d6
3
+ metadata.gz: a7e840571a249a64b262bfc9bf8527a8035f9af1
4
+ data.tar.gz: 1af56f855f62cd025389c36691459142a2b3ef78
5
5
  SHA512:
6
- metadata.gz: 312e9432006f123571e33cf44260c6e345d0d7585adec3d0b6bcf1eec6c0334d5228efe1973d805a05dede3c41ec214182271127bc9d35cb72049044179c7357
7
- data.tar.gz: d0c85a0549b2f4d5df589bdcb49754ab857483333fe681e9f7d44d050132d9313fece11bee61fa751c58e94ddffdba135b8299d3cdb47cbde36d792ec060f92b
6
+ metadata.gz: f2a1732a324a908fbe3b7dabed0a9a77dd27f75123158460e682d0d353bef9369bb2ba4f661eebc143330f9719110a3dd69f86bb19018c8389cbf46e29480ee0
7
+ data.tar.gz: ede1f603e5815b1f6da2c74fdd3cc3a7395b65600ff2f6b0586208d1fc732698058e76716365cf91ec525202be9081396be779f9e4e0bf8806668abb6feed2ce
@@ -21,7 +21,9 @@ 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, {}, :deep_merge)
24
+ inherited_class_var(hidden_variable_name, {}) do |hash, to_merge|
25
+ hash.deep_merge!(to_merge) {|key,left,right| left } # a reverse_deep_merge! implementation, this will keep the parent's key order
26
+ end
25
27
  end
26
28
 
27
29
  define_singleton_method :"raw_#{variable_name}" do
@@ -75,14 +77,13 @@ module InheritedClassVar
75
77
  end
76
78
 
77
79
  # @param variable_name [Symbol] class variable name (recommend :@_variable_name)
78
- # @param default_value [Object] default value of the class variable
79
- # @param merge_method [Symbol] method to merge values of the class variable
80
80
  # @return [Object] a class variable merged across ancestors until inherited_class_module
81
- def inherited_class_var(variable_name, default_value, merge_method)
81
+ def inherited_class_var(variable_name, *reduce_args, &block)
82
82
  class_cache(variable_name) do
83
83
  inherited_ancestors.map { |ancestor| ancestor.instance_variable_get(variable_name) }
84
84
  .compact
85
- .reduce(default_value, merge_method)
85
+ .reverse
86
+ .reduce(*reduce_args, &block)
86
87
  end
87
88
  end
88
89
 
@@ -1,3 +1,3 @@
1
1
  module InheritedClassVar
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
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.1
4
+ version: 0.2.2
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-06-02 00:00:00.000000000 Z
12
+ date: 2016-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport