flat_keys 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/flat_keys/version.rb +1 -1
  2. data/lib/flat_keys.rb +12 -12
  3. metadata +1 -1
@@ -1,3 +1,3 @@
1
1
  module FlatKeys
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/flat_keys.rb CHANGED
@@ -1,18 +1,6 @@
1
1
  require_relative "flat_keys/version"
2
2
 
3
3
  class Hash
4
-
5
- def visit_flat_keys(hash, prefix, separator)
6
- self.each do |k, v|
7
- key = "#{prefix}#{k}"
8
- if v.is_a?(Hash)
9
- v.visit_flat_keys(hash, "#{key}#{separator}", separator)
10
- else
11
- hash[key] = v
12
- end
13
- end
14
- end
15
-
16
4
  def flat_keys(separator = ".")
17
5
  hash = {}
18
6
  visit_flat_keys(hash, "", separator)
@@ -37,5 +25,17 @@ class Hash
37
25
  hash
38
26
  end
39
27
 
28
+ protected
29
+
30
+ def visit_flat_keys(hash, prefix, separator)
31
+ self.each do |k, v|
32
+ key = "#{prefix}#{k}"
33
+ if v.is_a?(Hash)
34
+ v.visit_flat_keys(hash, "#{key}#{separator}", separator)
35
+ else
36
+ hash[key] = v
37
+ end
38
+ end
39
+ end
40
40
  end
41
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flat_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: