black_hole_struct 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/black_hole_struct.rb +9 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e81622183c98e979e788f8f2843fc65ade830f05
|
4
|
+
data.tar.gz: 1a3bf812813156ba3e86b0b1d38936127fcc4539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b53adc0e9e65c928c51748ac7701d3257f27350a4ea1eba5e9bb10485d8a8d6ad360d4b6a706980df6328ed81faeec0bf59ef7533390aed7120ac4d4a3eae1d4
|
7
|
+
data.tar.gz: 7cf886b1d42ab5a470c3d7474b80b2828231b0f802e17457831e70e269cf1ced5afc03bf66cbbe596601ef19d3fb6e2700d4f7aa38990f21cea44418c59995d7
|
data/README.md
CHANGED
@@ -13,13 +13,13 @@
|
|
13
13
|
Add it to your Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem "
|
16
|
+
gem "black_hole_struct"
|
17
17
|
```
|
18
18
|
|
19
19
|
Or install the gem manually:
|
20
20
|
|
21
21
|
```sh
|
22
|
-
$ gem install
|
22
|
+
$ gem install black_hole_struct
|
23
23
|
```
|
24
24
|
|
25
25
|
## Basic Usage
|
data/lib/black_hole_struct.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# infinite chaining of attributes or [autovivification](https://en.wikipedia.org/wiki/Autovivification).
|
3
3
|
class BlackHoleStruct
|
4
4
|
# Current version
|
5
|
-
VERSION = "0.1.
|
5
|
+
VERSION = "0.1.3"
|
6
6
|
|
7
7
|
# BlackHoleStruct can be optionally initialized with a Hash
|
8
8
|
# @param [Hash] hash Initialize with a hash
|
@@ -49,12 +49,17 @@ class BlackHoleStruct
|
|
49
49
|
@table[key.to_sym] = self.class.new
|
50
50
|
end
|
51
51
|
|
52
|
-
# Calls block once for each key
|
52
|
+
# Calls block once for each key passing the key-value pair as parameters.
|
53
53
|
# if no block is given, an Enumerator is returned instead.
|
54
54
|
# @yield [key, value]
|
55
|
-
def each_pair
|
56
|
-
@table.each_pair
|
55
|
+
def each_pair(&block)
|
56
|
+
return @table.each_pair unless block
|
57
|
+
|
58
|
+
@table.each_pair do |key, value|
|
59
|
+
yield key, value
|
60
|
+
end
|
57
61
|
end
|
62
|
+
alias :each :each_pair
|
58
63
|
|
59
64
|
# Returns a new hash with self and other_hash merged.
|
60
65
|
# @param [Hash] other_hash
|