hash_flattener 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,8 @@ require_relative 'hash_flattener/hash_flattener'
2
2
 
3
3
  module HashFlattener
4
4
 
5
- def self.flatten(hash, options={})
6
- HashFlattener.new(hash, options).flatten
5
+ def self.flatten(hash, delimiter=DEFAULT_DELIMITER)
6
+ HashFlattener.new.flatten hash, delimiter
7
7
  end
8
8
 
9
9
  end
@@ -1,12 +1,12 @@
1
1
  module HashFlattener
2
- class HashFlattener
3
2
 
4
- def initialize(hash, options={})
5
- @hash = hash
6
- @delimiter = options[:delimiter] || '.'
7
- end
3
+ DEFAULT_DELIMITER = '.'
4
+
5
+ class HashFlattener
8
6
 
9
- def flatten
7
+ def flatten(hash, delimiter=DEFAULT_DELIMITER)
8
+ @hash = hash.kind_of?(Hash) ? hash : hash.to_hash
9
+ @delimiter = delimiter.to_s
10
10
  flatten_enumerable @hash
11
11
  end
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_flattener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-13 00:00:00.000000000 Z
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70363807617900 !ruby/object:Gem::Requirement
16
+ requirement: &70204361692180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70363807617900
24
+ version_requirements: *70204361692180
25
25
  description:
26
26
  email: matthew-github@matthewriley.name
27
27
  executables: []