hashable 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
1
  require 'hashable/version'
2
2
  require 'hashable/hashable'
3
- require 'hashable/hash'
3
+ require 'hashable/hash'
4
+ require 'hashable/array'
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/hashable'
2
+
3
+ class Array
4
+ include Hashable
5
+ # Return recursively hash representation of the given array
6
+ #
7
+ # @return array
8
+ def to_deep_hash
9
+ new_array = []
10
+ self.each_index do |index|
11
+ new_array[index] = deeply_to_hash(self[index])
12
+ end
13
+ new_array
14
+ end
15
+ alias_method :to_dh, :to_deep_hash
16
+ end
@@ -5,7 +5,7 @@ class Hash
5
5
 
6
6
  # Return recursively hash representation of the given hash
7
7
  #
8
- # @return Base object instance variables in a Hash
8
+ # @return hash
9
9
  def to_deep_hash
10
10
  hash = {}
11
11
  self.keys.each do |key|
@@ -1,3 +1,3 @@
1
1
  module Hashable
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -58,6 +58,7 @@ files:
58
58
  - Rakefile
59
59
  - hashable.gemspec
60
60
  - lib/hashable.rb
61
+ - lib/hashable/array.rb
61
62
  - lib/hashable/hash.rb
62
63
  - lib/hashable/hashable.rb
63
64
  - lib/hashable/version.rb