hash_dot 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 025bbbf6717d54caf3ac01e47c898c073fd92807
4
- data.tar.gz: 56fe882509329f3c75b7ac26cca082a608a151ad
3
+ metadata.gz: 4053d02b0efc655dfe83f7a8a6e774f08d255695
4
+ data.tar.gz: 2f3578986611a226fabc119579a7f86c14c42016
5
5
  SHA512:
6
- metadata.gz: 1d132f533f12e56e2eae538007eff03c5c2839d16445040de3b2eda9d678903fc25958506b90f44556582a705676259b165330dcc34202b01702da3f165276ce
7
- data.tar.gz: 7c9ca35e1a9cb15fb3b99b12f2b137cba4a42c1c20c5cbb79a8a950d5595f0bd52146dd9a09ca989a5e3b351cb3cbcffc8b0eb7076ce4b921c1551519929e098
6
+ metadata.gz: 1f36b8a4c8597099cf48ae162ff54f9f32c9c2400f748663688e09c0f1f9ff57d4bc0606d03d3254aab9d425314ff6d1c985ee3d78890c66aea13010572d089b
7
+ data.tar.gz: 3b24ff46015a9fc45a6dc117f5a1c0f306ba128be3cb47e821f61d6672464b3c412dc1ae7ee3437a0ad5459a7fa246a7b65d224fdb814c868d0dae21c5fbe583
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.0
3
+ - 2.3.6
4
+ - 2.4.2
5
+ - 2.5.0
4
6
  before_install: gem install bundler -v 1.10.3
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 #=> {:name=>'Anna', :job=>{:title=>'Engineer', :department=>'DevOps'}}
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)
@@ -1,3 +1,3 @@
1
1
  module HashDot
2
- VERSION = "2.3.0".freeze
2
+ VERSION = "2.4.0".freeze
3
3
  end
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.3.0
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-01-16 00:00:00.000000000 Z
11
+ date: 2018-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler