hash_dot 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +4 -2
- data/lib/hash.rb +4 -0
- data/lib/hash_dot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4053d02b0efc655dfe83f7a8a6e774f08d255695
|
|
4
|
+
data.tar.gz: 2f3578986611a226fabc119579a7f86c14c42016
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f36b8a4c8597099cf48ae162ff54f9f32c9c2400f748663688e09c0f1f9ff57d4bc0606d03d3254aab9d425314ff6d1c985ee3d78890c66aea13010572d089b
|
|
7
|
+
data.tar.gz: 3b24ff46015a9fc45a6dc117f5a1c0f306ba128be3cb47e821f61d6672464b3c412dc1ae7ee3437a0ad5459a7fa246a7b65d224fdb814c868d0dae21c5fbe583
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -18,7 +18,10 @@ HashDot allows you to get and set your Ruby hash properties with a dot syntax.
|
|
|
18
18
|
user.job.title #=> 'Engineer'
|
|
19
19
|
user.job.department = 'DevOps'
|
|
20
20
|
user.job.department #=> 'DevOps'
|
|
21
|
-
user
|
|
21
|
+
user.send('beverages=', {}.to_dot)
|
|
22
|
+
user.send('beverages.coffee=', 'Short Black')
|
|
23
|
+
user.send('beverages.coffee') #=> 'Short Black'
|
|
24
|
+
user #=> {:name=>'Anna', :job=>{:title=>'Engineer', :department=>'DevOps'}, :beverages=> { :coffee => 'Short Black'} }
|
|
22
25
|
```
|
|
23
26
|
|
|
24
27
|
You can also allow dot syntax for all hashes via the class setting.
|
|
@@ -115,4 +118,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/adstee
|
|
|
115
118
|
## License
|
|
116
119
|
|
|
117
120
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
118
|
-
|
data/lib/hash.rb
CHANGED
|
@@ -16,6 +16,10 @@ class Hash
|
|
|
16
16
|
def method_missing(method, *args)
|
|
17
17
|
return super(method, *args) unless to_dot?
|
|
18
18
|
|
|
19
|
+
method, chain = method.to_s.split('.', 2).map(&:to_sym)
|
|
20
|
+
|
|
21
|
+
return send(method).send(chain, *args) if chain
|
|
22
|
+
|
|
19
23
|
prop = create_prop(method)
|
|
20
24
|
|
|
21
25
|
if setter?(method)
|
data/lib/hash_dot/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hash_dot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Steel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-02-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|