hashd 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/hashd.gemspec +1 -1
- data/lib/hashd/hash.rb +11 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6974e36189c3cc51df299521ae90bfac6dc0bb88
|
4
|
+
data.tar.gz: e2bc3b72188924c27629173fee58426f01de146e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488d0f0dedb0cbb8970456b60559bb86721ab274c7cdf0d03fcaa215e6d8344aa15c99bd850b0bd858701fa36e4b733a6b6b39ad005134a7c123fc23d9600024
|
7
|
+
data.tar.gz: 52c1caa0ea4197aa02b86700c0eff2f17021cee0c829908be02c5df9d0c08e5615697e529ac4ac0e92d16ef750a6d0dc2406283c021ab99d36e24a0bc077a50d
|
data/CHANGELOG.md
ADDED
data/hashd.gemspec
CHANGED
data/lib/hashd/hash.rb
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
class Hash
|
2
2
|
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :use_dot_syntax
|
4
4
|
|
5
5
|
def to_dot
|
6
6
|
dotify(self); self
|
7
7
|
end
|
8
8
|
|
9
|
+
# Using method missing.
|
9
10
|
def method_missing(name, *args, &block)
|
10
|
-
return super(name, *args, &block) unless
|
11
|
+
return super(name, *args, &block) unless use_dot_syntax
|
11
12
|
|
13
|
+
# Check for value first or assign
|
12
14
|
if name[-1] == '='
|
13
|
-
self[name[0..-2].to_sym] = args[0]
|
14
|
-
|
15
|
-
|
15
|
+
return self[name[0..-2].to_sym] = args[0]
|
16
|
+
elsif (val = self[name] || self[name.to_s])
|
17
|
+
return val
|
16
18
|
end
|
19
|
+
|
20
|
+
# Pass to methods if value not found
|
21
|
+
return super(name, *args, &block) if self.respond_to?(name)
|
17
22
|
end
|
18
23
|
|
19
24
|
private
|
20
25
|
|
21
26
|
# Set up each hash for dot syntax
|
22
27
|
def dotify(h)
|
23
|
-
h.
|
28
|
+
h.use_dot_syntax = true; h.keys.each{|key| dotify(h[key]) if h[key].is_a?(::Hash)}
|
24
29
|
end
|
25
30
|
|
26
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- CHANGELOG.md
|
35
36
|
- Gemfile
|
36
37
|
- LICENSE
|
37
38
|
- README.md
|